fixed race condition during shutdown

This commit is contained in:
john30
2017-04-22 19:04:00 +02:00
parent 930ae49513
commit 52a1675e7d
3 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -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));
+1 -1
View File
@@ -100,7 +100,7 @@ result_t UserList::addFromFile(map<string, string>& row, vector< map<string, str
MainLoop::MainLoop(const struct options opt, Device *device, MessageMap* messages)
: Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages),
m_address(opt.address), m_scanConfig(opt.scanConfig),
m_initialScan(opt.initialScan), m_enableHex(opt.enableHex) {
m_initialScan(opt.initialScan), m_enableHex(opt.enableHex), m_shutdown(false) {
// open Device
result_t result = m_device->open();
if (result != RESULT_OK) {
+5
View File
@@ -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.