From: Michał Kępień Date: Fri, 19 Apr 2019 07:37:51 +0000 (+0200) Subject: win32: fix service state reported during shutdown X-Git-Tag: v9.15.0~39^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=964749dfdbb51b4f1626edf1eb97df33600c10ae;p=thirdparty%2Fbind9.git win32: fix service state reported during shutdown When a Windows service receives a request to stop, it should not set its state to SERVICE_STOPPED until it is completely shut down as doing that allows the operating system to kill that service prematurely, which in the case of named may e.g. prevent the PID file and/or the lock file from being cleaned up. Set service state to SERVICE_STOP_PENDING when named begins its shutdown and only report the SERVICE_STOPPED state immediately before exiting. --- diff --git a/bin/named/win32/ntservice.c b/bin/named/win32/ntservice.c index dbb19c9beac..986993f4f1a 100644 --- a/bin/named/win32/ntservice.c +++ b/bin/named/win32/ntservice.c @@ -81,7 +81,7 @@ ServiceControl(DWORD dwCtrlCode) { case SERVICE_CONTROL_STOP: named_server_flushonshutdown(named_g_server, true); isc_app_shutdown(); - UpdateSCM(SERVICE_STOPPED); + UpdateSCM(SERVICE_STOP_PENDING); break; default: break;