Skip to content

Commit

Permalink
Fix another deadlock in sensors system (#2141)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Sep 20, 2023
1 parent bb6753a commit 509d01a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,12 @@ void SensorsPrivate::RunOnce()
this->activeSensors.clear();
}

this->updateAvailable = false;
this->forceUpdate = false;
this->renderCv.notify_one();
{
std::unique_lock<std::mutex> cvLock(this->renderMutex);
this->updateAvailable = false;
this->renderCv.notify_one();
}
}

//////////////////////////////////////////////////
Expand Down Expand Up @@ -746,9 +749,12 @@ void Sensors::PostUpdate(const UpdateInfo &_info,
this->dataPtr->forceUpdate =
(this->dataPtr->renderUtil.PendingSensors() > 0) ||
hasRenderConnections;
}
{
std::unique_lock<std::mutex> cvLock(this->dataPtr->renderMutex);
this->dataPtr->updateAvailable = true;
this->dataPtr->renderCv.notify_one();
}
this->dataPtr->renderCv.notify_one();
}
}
}
Expand Down

0 comments on commit 509d01a

Please sign in to comment.