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 committed Oct 10, 2023
1 parent ba40627 commit 664054c
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 @@ -389,9 +389,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 @@ -726,9 +729,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 664054c

Please sign in to comment.