fixed race condition during shutdown
This commit is contained in:
+2
-2
@@ -669,11 +669,11 @@ void signalHandler(int sig) {
|
|||||||
break;
|
break;
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
logNotice(lf_main, "SIGINT received");
|
logNotice(lf_main, "SIGINT received");
|
||||||
shutdown();
|
s_mainLoop->join();
|
||||||
break;
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
logNotice(lf_main, "SIGTERM received");
|
logNotice(lf_main, "SIGTERM received");
|
||||||
shutdown();
|
s_mainLoop->join();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logNotice(lf_main, "undefined signal %s", strsignal(sig));
|
logNotice(lf_main, "undefined signal %s", strsignal(sig));
|
||||||
|
|||||||
@@ -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)
|
MainLoop::MainLoop(const struct options opt, Device *device, MessageMap* messages)
|
||||||
: Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages),
|
: Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages),
|
||||||
m_address(opt.address), m_scanConfig(opt.scanConfig),
|
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
|
// open Device
|
||||||
result_t result = m_device->open();
|
result_t result = m_device->open();
|
||||||
if (result != RESULT_OK) {
|
if (result != RESULT_OK) {
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ class MainLoop : public Thread, DeviceListener {
|
|||||||
*/
|
*/
|
||||||
~MainLoop();
|
~MainLoop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shutdown the main loop.
|
||||||
|
*/
|
||||||
|
void shutdown() { m_shutdown = true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the @a BusHandler instance.
|
* Get the @a BusHandler instance.
|
||||||
* @return the created @a BusHandler instance.
|
* @return the created @a BusHandler instance.
|
||||||
|
|||||||
Reference in New Issue
Block a user