From e00dcf2fb5b991f381b75b0f96553f7e2e478361 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 13 Jan 2014 12:08:17 +0000 Subject: [PATCH] Don't get stuck in SERVICE_CONTINUE_PENDING. If we received SERVICE_CONTROL_CONTINUE and the service wasn't paused we would incorrectly set SERVICE_CONTINUE_PENDING status. The Windows services console won't allow a user to attempt to send a continue control to a running service but other applications, like say NSSM itself, might happily try, then get confused when the status wasn't set to SERVICE_RUNNING. --- service.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service.cpp b/service.cpp index fbbab20..aee0a67 100644 --- a/service.cpp +++ b/service.cpp @@ -1456,7 +1456,8 @@ unsigned long WINAPI service_control_handler(unsigned long control, unsigned lon ZeroMemory(&service->throttle_duetime, sizeof(service->throttle_duetime)); SetWaitableTimer(service->throttle_timer, &service->throttle_duetime, 0, 0, 0, 0); } - service->status.dwCurrentState = SERVICE_CONTINUE_PENDING; + /* We can't continue if the application is running! */ + if (! service->process_handle) service->status.dwCurrentState = SERVICE_CONTINUE_PENDING; service->status.dwWaitHint = throttle_milliseconds(service->throttle) + NSSM_WAITHINT_MARGIN; log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_RESET_THROTTLE, service->name, 0); SetServiceStatus(service->status_handle, &service->status); -- 2.7.4