Skip to content

Commit

Permalink
Fix double-locking issue in DataSharingListener (#5468)
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaojing Cao <[email protected]>
(cherry picked from commit 059457a)
  • Loading branch information
xjzer authored and mergify[bot] committed Dec 20, 2024
1 parent 7e6ff9d commit cca8d1a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/cpp/rtps/DataSharing/DataSharingListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ DataSharingListener::~DataSharingListener()

void DataSharingListener::run()
{
std::unique_lock<Segment::mutex> lock(notification_->notification_->notification_mutex, std::defer_lock);
while (is_running_.load())
{
try
{
lock.lock();
std::unique_lock<Segment::mutex> lock(notification_->notification_->notification_mutex);
notification_->notification_->notification_cv.wait(lock, [&]
{
return !is_running_.load() || notification_->notification_->new_data.load();
});

lock.unlock();
}
catch (const boost::interprocess::interprocess_exception& /*e*/)
{
Expand Down

0 comments on commit cca8d1a

Please sign in to comment.