Fix race condition, ignore errors when sending measurements and reading control

This commit is contained in:
nsubiron 2018-03-22 16:24:13 +01:00
parent 367fb6f284
commit 8c65896c65
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.
}
}