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]>
  • Loading branch information
xjzer authored Dec 20, 2024
1 parent 0207274 commit 059457a
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 @@ -56,18 +56,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 059457a

Please sign in to comment.