From 52a1675e7dfd63978c2c43c5fd8c22cae51a48f5 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 22 Apr 2017 19:04:00 +0200 Subject: [PATCH] fixed race condition during shutdown --- src/ebusd/main.cpp | 4 ++-- src/ebusd/mainloop.cpp | 2 +- src/ebusd/mainloop.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index ff066960..afcd37e1 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -669,11 +669,11 @@ void signalHandler(int sig) { break; case SIGINT: logNotice(lf_main, "SIGINT received"); - shutdown(); + s_mainLoop->join(); break; case SIGTERM: logNotice(lf_main, "SIGTERM received"); - shutdown(); + s_mainLoop->join(); break; default: logNotice(lf_main, "undefined signal %s", strsignal(sig)); diff --git a/src/ebusd/mainloop.cpp b/src/ebusd/mainloop.cpp index ce809683..333a719b 100644 --- a/src/ebusd/mainloop.cpp +++ b/src/ebusd/mainloop.cpp @@ -100,7 +100,7 @@ result_t UserList::addFromFile(map& row, vector< mapopen(); if (result != RESULT_OK) { diff --git a/src/ebusd/mainloop.h b/src/ebusd/mainloop.h index f0c3c23d..d9d558d2 100644 --- a/src/ebusd/mainloop.h +++ b/src/ebusd/mainloop.h @@ -112,6 +112,11 @@ class MainLoop : public Thread, DeviceListener { */ ~MainLoop(); + /** + * Shutdown the main loop. + */ + void shutdown() { m_shutdown = true; } + /** * Get the @a BusHandler instance. * @return the created @a BusHandler instance.