diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2023-02-24 11:41:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 11:41:58 +0200 |
commit | 13b34502c10d62c2210c1f624b37c96d3278b8a9 (patch) | |
tree | c0e91ed3e9ac6dc5356165710c0fb27c98369428 /daemon | |
parent | 59a1a528e3e42e90eda83f7cfe7b04fe8a00e60d (diff) |
Prevent core dump when the agent is performing a quick shutdown (#14587)
* Prevent core dump when the agent is performing a quick shutdown (e.g. when rrd_init fails)
* Threads that have not started during shutdown are immediately marked as EXITED
* Do not attempt to get statistics if database is not initialized
* Do not attempt to get context db statistics if the context database is not initialized
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/main.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/daemon/main.c b/daemon/main.c index fd9c1c922f..d39a76da3e 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -656,9 +656,14 @@ void cancel_main_threads() { int i, found = 0; usec_t max = 5 * USEC_PER_SEC, step = 100000; for (i = 0; static_threads[i].name != NULL ; i++) { - if(static_threads[i].enabled == NETDATA_MAIN_THREAD_RUNNING) { - info("EXIT: Stopping main thread: %s", static_threads[i].name); - netdata_thread_cancel(*static_threads[i].thread); + if (static_threads[i].enabled == NETDATA_MAIN_THREAD_RUNNING) { + if (static_threads[i].thread) { + info("EXIT: Stopping main thread: %s", static_threads[i].name); + netdata_thread_cancel(*static_threads[i].thread); + } else { + info("EXIT: No thread running (marking as EXITED): %s", static_threads[i].name); + static_threads[i].enabled = NETDATA_MAIN_THREAD_EXITED; + } found++; } } |