Fix race condition
This commit is contained in:
Néstor Subirón 2018-03-23 18:22:43 +01:00 committed by GitHub
commit 486d1873db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 12 deletions

View File

@ -121,7 +121,7 @@ void FServerGameController::Tick(float DeltaSeconds)
// Send measurements. // Send measurements.
{ {
if(CarlaSettings->bSynchronousMode) if (CarlaSettings->bSynchronousMode)
{ {
FlushRenderingCommands(); FlushRenderingCommands();
} }
@ -131,7 +131,8 @@ void FServerGameController::Tick(float DeltaSeconds)
DataRouter.GetAgents(), DataRouter.GetAgents(),
CarlaSettings->bSendNonPlayerAgentsInfo)) CarlaSettings->bSendNonPlayerAgentsInfo))
{ {
Server = nullptr; // The error here must be ignored, otherwise we can create a race
// condition between the different ports.
return; return;
} }
} }
@ -140,12 +141,10 @@ void FServerGameController::Tick(float DeltaSeconds)
{ {
const bool bShouldBlock = CarlaSettings->bSynchronousMode; const bool bShouldBlock = CarlaSettings->bSynchronousMode;
FVehicleControl Control; FVehicleControl Control;
if (Errc::Error == Server->ReadControl(Control, bShouldBlock)) { if (Errc::Error != Server->ReadControl(Control, bShouldBlock))
Server = nullptr; {
return;
} else {
DataRouter.ApplyVehicleControl(Control); DataRouter.ApplyVehicleControl(Control);
} } // Here we ignore the error too.
} }
} }