From: Iain Patterson Date: Wed, 13 Nov 2013 15:34:26 +0000 (+0000) Subject: Use override_milliseconds() to find throttle restart delay. X-Git-Tag: v2.18~8 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=a9269d8370b339777c32e6e4a5e5be3ad7387a1c;p=nssm.git Use override_milliseconds() to find throttle restart delay. Use the new override_milliseconds() helper to find the override for the amount of time to wait when throttling restarts. --- diff --git a/registry.cpp b/registry.cpp index a1332b2..7a7b784 100644 --- a/registry.cpp +++ b/registry.cpp @@ -300,28 +300,12 @@ int get_parameters(char *service_name, char *exe, unsigned long exelen, char *fl } /* Try to get throttle restart delay */ - unsigned long type = REG_DWORD; - unsigned long buflen = sizeof(*throttle_delay); - bool throttle_ok = false; - ret = RegQueryValueEx(key, NSSM_REG_THROTTLE, 0, &type, (unsigned char *) throttle_delay, &buflen); - if (ret != ERROR_SUCCESS) { - if (ret != ERROR_FILE_NOT_FOUND) { - if (type != REG_DWORD) { - char milliseconds[16]; - _snprintf_s(milliseconds, sizeof(milliseconds), _TRUNCATE, "%lu", NSSM_RESET_THROTTLE_RESTART); - log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_BOGUS_THROTTLE, service_name, NSSM_REG_THROTTLE, milliseconds, 0); - } - else log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, NSSM_REG_THROTTLE, error_string(GetLastError()), 0); - } - } - else throttle_ok = true; - - if (! throttle_ok) *throttle_delay = NSSM_RESET_THROTTLE_RESTART; + override_milliseconds(service_name, key, NSSM_REG_THROTTLE, throttle_delay, NSSM_RESET_THROTTLE_RESTART, NSSM_EVENT_BOGUS_THROTTLE); /* Try to get service stop flags. */ - type = REG_DWORD; + unsigned long type = REG_DWORD; unsigned long stop_method_skip; - buflen = sizeof(stop_method_skip); + unsigned long buflen = sizeof(stop_method_skip); bool stop_ok = false; ret = RegQueryValueEx(key, NSSM_REG_STOP_METHOD_SKIP, 0, &type, (unsigned char *) &stop_method_skip, &buflen); if (ret != ERROR_SUCCESS) {