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