aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryaworsky <yaworsky>2005-12-08 04:10:57 +0000
committeryaworsky <yaworsky>2005-12-08 04:10:57 +0000
commitacec0f1564d24d61f4a671703748963b0f7d5754 (patch)
tree95627c489f82ac2a6893e9a21b10ce12078a5698
parent975ba77d13227571797714115b64118078361720 (diff)
downloadsyslog-win32-acec0f1564d24d61f4a671703748963b0f7d5754.tar.gz
syslog-win32-acec0f1564d24d61f4a671703748963b0f7d5754.tar.xz
syslog-win32-acec0f1564d24d61f4a671703748963b0f7d5754.zip
Suppress error message when shutting down the daemon.
-rw-r--r--daemon/main.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/daemon/main.c b/daemon/main.c
index f45eac3..007ec54 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -251,8 +251,9 @@ static BOOL start_service()
/******************************************************************************
* shutdown_service
*/
-static void winnt_shutdown_service()
+static BOOL winnt_shutdown_service()
{
+ BOOL ret = FALSE;
SC_HANDLE hscm, hsvc;
int i;
@@ -260,7 +261,7 @@ static void winnt_shutdown_service()
if( !hscm )
{
TRACE( "OpenSCManager error %lu\n", GetLastError() );
- return;
+ return FALSE;
}
hsvc = OpenService( hscm, service_name, SERVICE_ALL_ACCESS );
@@ -268,7 +269,7 @@ static void winnt_shutdown_service()
{
TRACE( "OpenService error %lu\n", GetLastError() );
CloseServiceHandle( hscm );
- return;
+ return FALSE;
}
ControlService( hsvc, SERVICE_CONTROL_STOP, &sstatus );
@@ -281,25 +282,32 @@ static void winnt_shutdown_service()
break;
}
if( SERVICE_STOPPED == sstatus.dwCurrentState )
+ {
+ ret = TRUE;
break;
+ }
}
CloseServiceHandle( hsvc );
+ return ret;
}
static void shutdown_service( gboolean quiet )
{
+ BOOL stopped;
+
/* try to stop windows NT service */
- winnt_shutdown_service();
+ stopped = winnt_shutdown_service();
- /* set stop_event and wait for completion */
+ /* try to shutdown using stop_event because daemon may run not as service;
+ set event and wait for completion */
for(;;)
{
BOOL ret;
HANDLE he = OpenEvent( EVENT_MODIFY_STATE, FALSE, service_stop_event_name );
if( !he )
{
- if( !quiet )
+ if( (!quiet) && (!stopped) )
ERR( "cannot open event; error %lu\n", GetLastError() );
return;
}