summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c502259)
Try even harder to avoid race conditions whereby one thread reacts to an
application exit and performs a restart even after another thread has
committed to handling a stop control.
Thanks Runner Mei.
char flags[CMD_LENGTH];\r
char dir[MAX_PATH];\r
bool stopping;\r
char flags[CMD_LENGTH];\r
char dir[MAX_PATH];\r
bool stopping;\r
unsigned long throttle_delay;\r
unsigned long stop_method;\r
HANDLE throttle_timer;\r
unsigned long throttle_delay;\r
unsigned long stop_method;\r
HANDLE throttle_timer;\r
/* Start the service */\r
int start_service() {\r
stopping = false;\r
/* Start the service */\r
int start_service() {\r
stopping = false;\r
+ allow_restart = true;\r
\r
if (process_handle) return 0;\r
\r
\r
if (process_handle) return 0;\r
\r
\r
/* Stop the service */\r
int stop_service(unsigned long exitcode, bool graceful, bool default_action) {\r
\r
/* Stop the service */\r
int stop_service(unsigned long exitcode, bool graceful, bool default_action) {\r
+ allow_restart = false;\r
+ if (wait_handle) UnregisterWait(wait_handle);\r
+\r
if (default_action && ! exitcode && ! graceful) {\r
log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_GRACEFUL_SUICIDE, service_name, exe, exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_REALLY] ,0);\r
graceful = true;\r
if (default_action && ! exitcode && ! graceful) {\r
log_event(EVENTLOG_INFORMATION_TYPE, NSSM_EVENT_GRACEFUL_SUICIDE, service_name, exe, exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_UNCLEAN], exit_action_strings[NSSM_EXIT_REALLY] ,0);\r
graceful = true;\r
this is a controlled shutdown, and don't take any restart action.\r
*/\r
if (why) return;\r
this is a controlled shutdown, and don't take any restart action.\r
*/\r
if (why) return;\r
+ if (! allow_restart) return;\r
\r
/* What action should we take? */\r
int action = NSSM_EXIT_RESTART;\r
\r
/* What action should we take? */\r
int action = NSSM_EXIT_RESTART;\r