+\r
+void throttle_restart() {\r
+ /* This can't be a restart if the service is already running. */\r
+ if (! throttle++) return;\r
+\r
+ int ms = throttle_milliseconds();\r
+\r
+ if (throttle > 7) throttle = 8;\r
+\r
+ char threshold[8], milliseconds[8];\r
+ _snprintf(threshold, sizeof(threshold), "%d", NSSM_RESET_THROTTLE_RESTART);\r
+ _snprintf(milliseconds, sizeof(milliseconds), "%d", ms);\r
+ log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_THROTTLED, service_name, threshold, milliseconds, 0);\r
+\r
+ EnterCriticalSection(&throttle_section);\r
+\r
+ service_status.dwCurrentState = SERVICE_PAUSED;\r
+ SetServiceStatus(service_handle, &service_status);\r
+\r
+ SleepConditionVariableCS(&throttle_condition, &throttle_section, ms);\r
+\r
+ LeaveCriticalSection(&throttle_section);\r
+}\r