Communication: Fix issue where driver failing to open leaves dangling thread
parent
67bd1e616a
commit
a759c1faa9
|
|
@ -23,8 +23,10 @@ bool Communication::open() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!driver->open())
|
||||||
|
return false;
|
||||||
spawnThreads();
|
spawnThreads();
|
||||||
return driver->open();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Communication::spawnThreads() {
|
void Communication::spawnThreads() {
|
||||||
|
|
@ -39,13 +41,13 @@ void Communication::joinThreads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Communication::close() {
|
bool Communication::close() {
|
||||||
|
joinThreads();
|
||||||
|
|
||||||
if(!isOpen()) {
|
if(!isOpen()) {
|
||||||
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
joinThreads();
|
|
||||||
|
|
||||||
return driver->close();
|
return driver->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue