\r
/* Used for signalling a resume if the service pauses when throttled. */\r
throttle_timer = CreateWaitableTimer(0, 1, 0);\r
+ if (! throttle_timer) {\r
+ log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_CREATEWAITABLETIMER_FAILED, service_name, error_string(GetLastError()), 0);\r
+ }\r
\r
monitor_service();\r
}\r
return NO_ERROR;\r
\r
case SERVICE_CONTROL_CONTINUE:\r
+ if (! throttle_timer) return ERROR_CALL_NOT_IMPLEMENTED;\r
throttle = 0;\r
ZeroMemory(&throttle_duetime, sizeof(throttle_duetime));\r
SetWaitableTimer(throttle_timer, &throttle_duetime, 0, 0, 0, 0);\r
_snprintf(milliseconds, sizeof(milliseconds), "%d", ms);\r
log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_THROTTLED, service_name, threshold, milliseconds, 0);\r
\r
- ZeroMemory(&throttle_duetime, sizeof(throttle_duetime));\r
- throttle_duetime.QuadPart = 0 - (ms * 10000);\r
- SetWaitableTimer(throttle_timer, &throttle_duetime, 0, 0, 0, 0);\r
+ if (throttle_timer) {\r
+ ZeroMemory(&throttle_duetime, sizeof(throttle_duetime));\r
+ throttle_duetime.QuadPart = 0 - (ms * 10000LL);\r
+ SetWaitableTimer(throttle_timer, &throttle_duetime, 0, 0, 0, 0);\r
+ }\r
\r
service_status.dwCurrentState = SERVICE_PAUSED;\r
SetServiceStatus(service_handle, &service_status);\r
\r
- WaitForSingleObject(throttle_timer, INFINITE);\r
+ if (throttle_timer) WaitForSingleObject(throttle_timer, INFINITE);\r
+ else Sleep(ms);\r
}\r