mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Fix race conditions with Communication::waitForMessageSync
This commit is contained in:
+10
-4
@@ -236,11 +236,17 @@ bool Device::goOnline() {
|
||||
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds(5)) {
|
||||
if(latestResetStatus && latestResetStatus->comEnabled)
|
||||
break;
|
||||
|
||||
if(!com->sendCommand(Command::RequestStatusUpdate))
|
||||
return false;
|
||||
|
||||
com->waitForMessageSync(filter, std::chrono::milliseconds(100));
|
||||
bool failOut = false;
|
||||
com->waitForMessageSync([this, &failOut]() {
|
||||
if(!com->sendCommand(Command::RequestStatusUpdate)) {
|
||||
failOut = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, filter, std::chrono::milliseconds(100));
|
||||
if(failOut)
|
||||
return false;
|
||||
}
|
||||
|
||||
online = true;
|
||||
|
||||
Reference in New Issue
Block a user