Skip to content

Commit

Permalink
nagios hangs on reload while sending external command to cmd file
Browse files Browse the repository at this point in the history
Fix for issue NagiosEnterprises#319

In an earlier fix, I was apparently trying to be overly clever.
This fix, proposed by xaoc-krsk, does the trick.
  • Loading branch information
John C. Frickson committed Feb 22, 2017
1 parent ad9d527 commit cde8780
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
13 changes: 7 additions & 6 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 3 additions & 14 deletions base/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
Expand Down

0 comments on commit cde8780

Please sign in to comment.