Use override_milliseconds() to find throttle restart delay.
authorIain Patterson <me@iain.cx>
Wed, 13 Nov 2013 15:34:26 +0000 (15:34 +0000)
committerIain Patterson <me@iain.cx>
Fri, 15 Nov 2013 16:02:56 +0000 (16:02 +0000)
Use the new override_milliseconds() helper to find the override for the
amount of time to wait when throttling restarts.

registry.cpp

index a1332b2..7a7b784 100644 (file)
@@ -300,28 +300,12 @@ int get_parameters(char *service_name, char *exe, unsigned long exelen, char *fl
   }\r
 \r
   /* Try to get throttle restart delay */\r
-  unsigned long type = REG_DWORD;\r
-  unsigned long buflen = sizeof(*throttle_delay);\r
-  bool throttle_ok = false;\r
-  ret = RegQueryValueEx(key, NSSM_REG_THROTTLE, 0, &type, (unsigned char *) throttle_delay, &buflen);\r
-  if (ret != ERROR_SUCCESS) {\r
-    if (ret != ERROR_FILE_NOT_FOUND) {\r
-      if (type != REG_DWORD) {\r
-        char milliseconds[16];\r
-        _snprintf_s(milliseconds, sizeof(milliseconds), _TRUNCATE, "%lu", NSSM_RESET_THROTTLE_RESTART);\r
-        log_event(EVENTLOG_WARNING_TYPE, NSSM_EVENT_BOGUS_THROTTLE, service_name, NSSM_REG_THROTTLE, milliseconds, 0);\r
-      }\r
-      else log_event(EVENTLOG_ERROR_TYPE, NSSM_EVENT_QUERYVALUE_FAILED, NSSM_REG_THROTTLE, error_string(GetLastError()), 0);\r
-    }\r
-  }\r
-  else throttle_ok = true;\r
-\r
-  if (! throttle_ok) *throttle_delay = NSSM_RESET_THROTTLE_RESTART;\r
+  override_milliseconds(service_name, key, NSSM_REG_THROTTLE, throttle_delay, NSSM_RESET_THROTTLE_RESTART, NSSM_EVENT_BOGUS_THROTTLE);\r
 \r
   /* Try to get service stop flags. */\r
-  type = REG_DWORD;\r
+  unsigned long type = REG_DWORD;\r
   unsigned long stop_method_skip;\r
-  buflen = sizeof(stop_method_skip);\r
+  unsigned long buflen = sizeof(stop_method_skip);\r
   bool stop_ok = false;\r
   ret = RegQueryValueEx(key, NSSM_REG_STOP_METHOD_SKIP, 0, &type, (unsigned char *) &stop_method_skip, &buflen);\r
   if (ret != ERROR_SUCCESS) {\r