From cde8780d2f042472e75b1f7f56f187c634a2b06a Mon Sep 17 00:00:00 2001 From: "John C. Frickson" Date: Wed, 22 Feb 2017 15:51:35 -0600 Subject: [PATCH] nagios hangs on reload while sending external command to cmd file Fix for issue #319 In an earlier fix, I was apparently trying to be overly clever. This fix, proposed by xaoc-krsk, does the trick. --- Changelog | 13 +++++++------ base/commands.c | 17 +++-------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Changelog b/Changelog index ac60d1d68..ff791382a 100644 --- a/Changelog +++ b/Changelog @@ -5,12 +5,13 @@ Nagios Core 4 Change Log x.x.x - xxxx-xx-xx ------------------ FIXES -* Service hard state generation and host hard or soft down status -* Comments are duplicated through Nagios reload -* host hourly value is incorrectly dumped as json boolean -* Bug - Quick Search no longer allows search by IP -* Config: status_update_interval can not be set to 1 -* Check attempts not increasing if nagios is reloaded +* Service hard state generation and host hard or soft down status (John Frickson) +* Comments are duplicated through Nagios reload (John Frickson) +* host hourly value is incorrectly dumped as json boolean (John Frickson) +* Bug - Quick Search no longer allows search by IP (John Frickson) +* Config: status_update_interval can not be set to 1 (John Frickson) +* Check attempts not increasing if nagios is reloaded (John Frickson) +* nagios hangs on reload while sending external command to cmd file (John Frickson) ENHANCEMENTS * Feature Request: return code xxx out of bounds - include message as well (John Frickson) diff --git a/base/commands.c b/base/commands.c index 0a60596b4..268112cd0 100644 --- a/base/commands.c +++ b/base/commands.c @@ -137,9 +137,9 @@ static int command_input_handler(int sd, int events, void *discard) { int ret, cmd_ret; char *buf; unsigned long size; -#ifdef USE_NANOSLEEP - struct timespec ts; -#endif + + if (sigrestart) + return 0; ret = iocache_read(command_worker.ioc, sd); log_debug_info(DEBUGL_COMMANDS, 2, "Read %d bytes from command worker\n", ret); @@ -156,17 +156,6 @@ static int command_input_handler(int sd, int events, void *discard) { log_debug_info(DEBUGL_COMMANDS, 1, "Read raw external command '%s'\n", buf); } - /* wait while restarting because we may not be ready to handle commands */ - while (sigrestart) { -#ifdef USE_NANOSLEEP - ts.tv_sec = 0; - ts.tv_nsec = 10000000; - nanosleep(&ts, NULL); -#else - sleep(1); -#endif - } - if ((cmd_ret = process_external_command1(buf)) != CMD_ERROR_OK) { logit(NSLOG_EXTERNAL_COMMAND | NSLOG_RUNTIME_WARNING, TRUE, "External command error: %s\n", cmd_error_strerror(cmd_ret)); }