Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite02e056

Browse files
author
Neil Conway
committed
pg_autovacuum fixes from Dave Page:
- Dependency services may not be correctly registered when installing asa Windows Service.- The sleep time is changed from milliseconds to seconds as it shouldbe.- Error messages during service installation/removal are logged tostderr.
1 parent0960dc2 commite02e056

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

‎contrib/pg_autovacuum/pg_autovacuum.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Revisions by Christopher B. Browne, Liberty RMS
55
* Win32 Service code added by Dave Page
66
*
7-
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.27 2004/12/02 22:48:10 momjian Exp $
7+
* $PostgreSQL: pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v 1.28 2005/01/24 00:13:38 neilc Exp $
88
*/
99

1010
#include"postgres_fe.h"
@@ -22,11 +22,10 @@
2222
#include"pg_autovacuum.h"
2323

2424
#ifdefWIN32
25-
unsignedintsleep();
26-
2725
SERVICE_STATUSServiceStatus;
2826
SERVICE_STATUS_HANDLEhStatus;
2927
intappMode=0;
28+
chardeps[255];
3029
#endif
3130

3231
/* define atooid */
@@ -1073,6 +1072,7 @@ get_cmd_args(int argc, char *argv[])
10731072
#ifndefWIN32
10741073
args->daemonize=0;
10751074
#else
1075+
args->service_dependencies=0;
10761076
args->install_as_service=0;
10771077
args->remove_as_service=0;
10781078
args->service_user=0;
@@ -1166,7 +1166,17 @@ get_cmd_args(int argc, char *argv[])
11661166
exit(0);
11671167
#ifdefWIN32
11681168
case'E':
1169-
args->service_dependencies=optarg;
1169+
/*
1170+
* CreateService() expects a list of service
1171+
* dependencies as a NUL-separated, double-NUL
1172+
* terminated list (although we only allow the user to
1173+
* specify a single dependency). So we zero out the
1174+
* list first, and make sure to leave room for two NUL
1175+
* terminators.
1176+
*/
1177+
ZeroMemory(deps,sizeof(deps));
1178+
snprintf(deps,sizeof(deps)-2,"%s",optarg);
1179+
args->service_dependencies=deps;
11701180
break;
11711181
case'I':
11721182
args->install_as_service++;
@@ -1359,7 +1369,7 @@ ControlHandler(DWORD request)
13591369

13601370
/* Register with the Service Control Manager */
13611371
staticint
1362-
InstallService()
1372+
InstallService(void)
13631373
{
13641374
SC_HANDLEschService=NULL;
13651375
SC_HANDLEschSCManager=NULL;
@@ -1471,7 +1481,7 @@ InstallService()
14711481

14721482
/* Unregister from the Service Control Manager */
14731483
staticint
1474-
RemoveService()
1484+
RemoveService(void)
14751485
{
14761486
SC_HANDLEschService=NULL;
14771487
SC_HANDLEschSCManager=NULL;
@@ -1699,7 +1709,7 @@ VacuumLoop(int argc, char **argv)
16991709
fflush(LOGOUTPUT);
17001710
}
17011711

1702-
sleep(sleep_secs);/* Larger Pause between outer loops */
1712+
pg_usleep(sleep_secs*1000000);/* Larger Pause between outer loops */
17031713

17041714
gettimeofday(&then,0);/* Reset time counter */
17051715

@@ -1753,15 +1763,12 @@ main(int argc, char *argv[])
17531763
if (InstallService()!=0)
17541764
{
17551765
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf,0,NULL);
1756-
sprintf(logbuffer,"%s", (char*)lpMsgBuf);
1757-
log_entry(logbuffer,LVL_ERROR);
1758-
fflush(LOGOUTPUT);
1766+
fprintf(stderr,"Error: %s\n", (char*)lpMsgBuf);
17591767
exit(-1);
17601768
}
17611769
else
17621770
{
1763-
log_entry("Successfully installed Windows service",LVL_INFO);
1764-
fflush(LOGOUTPUT);
1771+
fprintf(stderr,"Successfully installed pg_autovacuum as a service.\n");
17651772
exit(0);
17661773
}
17671774
}
@@ -1772,15 +1779,12 @@ main(int argc, char *argv[])
17721779
if (RemoveService()!=0)
17731780
{
17741781
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |FORMAT_MESSAGE_FROM_SYSTEM,NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf,0,NULL);
1775-
sprintf(logbuffer,"%s", (char*)lpMsgBuf);
1776-
log_entry(logbuffer,LVL_ERROR);
1777-
fflush(LOGOUTPUT);
1782+
fprintf(stderr,"Error: %s\n", (char*)lpMsgBuf);
17781783
exit(-1);
17791784
}
17801785
else
17811786
{
1782-
log_entry("Successfully removed Windows service",LVL_INFO);
1783-
fflush(LOGOUTPUT);
1787+
fprintf(stderr,"Successfully removed pg_autovacuum as a service.\n");
17841788
exit(0);
17851789
}
17861790
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp