]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
win32: fix service state reported during shutdown
authorMichał Kępień <michal@isc.org>
Fri, 19 Apr 2019 07:37:51 +0000 (09:37 +0200)
committerMichał Kępień <michal@isc.org>
Fri, 19 Apr 2019 07:54:06 +0000 (09:54 +0200)
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.

(cherry picked from commit 964749dfdbb51b4f1626edf1eb97df33600c10ae)

bin/named/win32/ntservice.c

index 23a5dc4b40c9eaa2d80e0f70ca1ee6f64b62cc16..fe4ab5c44d30154ade59f01fb840c6f9ad2e4b04 100644 (file)
@@ -82,7 +82,7 @@ ServiceControl(DWORD dwCtrlCode) {
        case SERVICE_CONTROL_STOP:
                ns_server_flushonshutdown(ns_g_server, true);
                isc_app_shutdown();
-               UpdateSCM(SERVICE_STOPPED);
+               UpdateSCM(SERVICE_STOP_PENDING);
                break;
        default:
                break;