Re: [pgsql-hackers-win32] pg_autovacuum fails to start - 8.0 Release
"Dave Page" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.patches,gmane.comp.db.postgresql.devel.win32 |
|---|---|
| Message-ID | <E7F85A1B5FF8D44C8A1AF6885BC9A0E4528596@ratbert.vale-housing.co.uk> |
> -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Dave Page > Sent: 20 January 2005 15:29 > To: Harald Massa; [email protected] > Cc: Patches (PostgreSQL) > Subject: Re: [PATCHES] [pgsql-hackers-win32] pg_autovacuum > fails to start - 8.0 Release > > It appears I didn't read the docs properly when I write that > bit - the dependencies parameter passed to CreateService() is > supposed to be double-null terminated - a subtle point I missed :-( > > The attached patch fixes this. Harald - I can email an > updated .exe if you want to test, otherwise, you should be > able to use the current version if you cleanup the > HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pg_autova > cuum\DependOnService registry key. Sorry - the attached patch supercedes the original. It also directs errors when installing/removing the windows service to stderr, rather than other logs. Regards, Dave. ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
pg_autovacuum.c.diff
(application/octet-stream, 2.8 KB)
cvs diff -u pg_autovacuum.c (in directory C:\Documents and Settings\dpage\My Documents\CVS\pgsql\contrib\pg_autovacuum\)
Index: pg_autovacuum.c
===================================================================
RCS file: /projects/cvsroot/pgsql/contrib/pg_autovacuum/pg_autovacuum.c,v
retrieving revision 1.27
diff -u -r1.27 pg_autovacuum.c
--- pg_autovacuum.c 2 Dec 2004 22:48:10 -0000 1.27
+++ pg_autovacuum.c 21 Jan 2005 09:23:05 -0000
@@ -27,6 +27,7 @@
SERVICE_STATUS ServiceStatus;
SERVICE_STATUS_HANDLE hStatus;
int appMode = 0;
+char deps[255];
#endif
/* define atooid */
@@ -1073,6 +1074,7 @@
#ifndef WIN32
args->daemonize = 0;
#else
+ args->service_dependencies = 0;
args->install_as_service = 0;
args->remove_as_service = 0;
args->service_user = 0;
@@ -1166,7 +1168,9 @@
exit(0);
#ifdef WIN32
case 'E':
- args->service_dependencies = optarg;
+ ZeroMemory(deps, sizeof(deps));
+ snprintf(deps, sizeof(deps) - 2, "%s", optarg);
+ args->service_dependencies = (char *)deps;
break;
case 'I':
args->install_as_service++;
@@ -1359,7 +1363,7 @@
/* Register with the Service Control Manager */
static int
-InstallService()
+InstallService(void)
{
SC_HANDLE schService = NULL;
SC_HANDLE schSCManager = NULL;
@@ -1471,7 +1475,7 @@
/* Unregister from the Service Control Manager */
static int
-RemoveService()
+RemoveService(void)
{
SC_HANDLE schService = NULL;
SC_HANDLE schSCManager = NULL;
@@ -1753,15 +1757,12 @@
if (InstallService() != 0)
{
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL);
- sprintf(logbuffer, "%s", (char *) lpMsgBuf);
- log_entry(logbuffer, LVL_ERROR);
- fflush(LOGOUTPUT);
+ fprintf(stderr, "Error: %s\n", (char *) lpMsgBuf);
exit(-1);
}
else
{
- log_entry("Successfully installed Windows service", LVL_INFO);
- fflush(LOGOUTPUT);
+ fprintf(stderr, "Successfully installed pg_autovacuum as a service.\n");
exit(0);
}
}
@@ -1772,15 +1773,12 @@
if (RemoveService() != 0)
{
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL);
- sprintf(logbuffer, "%s", (char *) lpMsgBuf);
- log_entry(logbuffer, LVL_ERROR);
- fflush(LOGOUTPUT);
+ fprintf(stderr, "Error: %s\n", (char *) lpMsgBuf);
exit(-1);
}
else
{
- log_entry("Successfully removed Windows service", LVL_INFO);
- fflush(LOGOUTPUT);
+ fprintf(stderr, "Successfully removed pg_autovacuum as a service.\n");
exit(0);
}
}