فهرست منبع

Calculate service stop wait hint correctly.

The wait hint when changing the service status to stopped failed to take
into account the grace period after sending a Control-C event.  It also
failed to consider the case where one or more stop methods were
disabled.
Iain Patterson 10 سال پیش
والد
کامیت
ee52ab253b
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      service.cpp

+ 4 - 1
service.cpp

@@ -445,7 +445,10 @@ int stop_service(unsigned long exitcode, bool graceful, bool default_action) {
   /* Signal we are stopping */
   if (graceful) {
     service_status.dwCurrentState = SERVICE_STOP_PENDING;
-    service_status.dwWaitHint = NSSM_KILL_WINDOW_GRACE_PERIOD + NSSM_KILL_THREADS_GRACE_PERIOD + NSSM_WAITHINT_MARGIN;
+    service_status.dwWaitHint = NSSM_WAITHINT_MARGIN;
+    if (stop_method & NSSM_STOP_METHOD_CONSOLE && imports.AttachConsole) service_status.dwWaitHint += NSSM_KILL_CONSOLE_GRACE_PERIOD;
+    if (stop_method & NSSM_STOP_METHOD_WINDOW) service_status.dwWaitHint += NSSM_KILL_WINDOW_GRACE_PERIOD;
+    if (stop_method & NSSM_STOP_METHOD_THREADS) service_status.dwWaitHint += NSSM_KILL_THREADS_GRACE_PERIOD;
     SetServiceStatus(service_handle, &service_status);
   }