Communication: Fix issue where driver failing to open leaves dangling thread

pull/25/head
Paul Hollinsky 2020-06-24 22:03:31 -04:00
parent 67bd1e616a
commit a759c1faa9
1 changed files with 5 additions and 3 deletions

View File

@ -23,8 +23,10 @@ bool Communication::open() {
return false;
}
if(!driver->open())
return false;
spawnThreads();
return driver->open();
return true;
}
void Communication::spawnThreads() {
@ -39,13 +41,13 @@ void Communication::joinThreads() {
}
bool Communication::close() {
joinThreads();
if(!isOpen()) {
report(APIEvent::Type::DeviceCurrentlyClosed, APIEvent::Severity::Error);
return false;
}
joinThreads();
return driver->close();
}