case SERVICE_CONTROL_STOP:\r
case SERVICE_CONTROL_SHUTDOWN:\r
switch (status) {\r
+ case SERVICE_RUNNING:\r
case SERVICE_STOP_PENDING:\r
return 1;\r
\r
}\r
\r
case SERVICE_CONTROL_INTERROGATE:\r
+ case NSSM_SERVICE_CONTROL_ROTATE:\r
return 0;\r
}\r
\r
\r
static inline int await_service_control_response(unsigned long control, SC_HANDLE service_handle, SERVICE_STATUS *service_status, unsigned long initial_status) {\r
int tries = 0;\r
+ unsigned long checkpoint = 0;\r
+ unsigned long waithint = 0;\r
while (QueryServiceStatus(service_handle, service_status)) {\r
int response = service_control_response(control, service_status->dwCurrentState);\r
/* Alas we can't WaitForSingleObject() on an SC_HANDLE. */\r
if (! response) return response;\r
if (response > 0 || service_status->dwCurrentState == initial_status) {\r
- if (++tries > 10) return response;\r
+ if (service_status->dwCheckPoint != checkpoint || service_status->dwWaitHint != waithint) tries = 0;\r
+ checkpoint = service_status->dwCheckPoint;\r
+ waithint = service_status->dwWaitHint;\r
+ if (++tries > 10) tries = 10;\r
Sleep(50 * tries);\r
}\r
else return response;\r