From cca8d1a30dbbf86b86cd01e1448974c4e57ace15 Mon Sep 17 00:00:00 2001 From: xjzer <62737335+xjzer@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:47:18 +0800 Subject: [PATCH] Fix double-locking issue in `DataSharingListener` (#5468) Signed-off-by: Xiaojing Cao (cherry picked from commit 059457aad375a3d9422acd1336f2e3e4f55a11c0) --- src/cpp/rtps/DataSharing/DataSharingListener.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cpp/rtps/DataSharing/DataSharingListener.cpp b/src/cpp/rtps/DataSharing/DataSharingListener.cpp index 66c9a3aafa5..f412b773dbf 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.cpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.cpp @@ -53,18 +53,15 @@ DataSharingListener::~DataSharingListener() void DataSharingListener::run() { - std::unique_lock lock(notification_->notification_->notification_mutex, std::defer_lock); while (is_running_.load()) { try { - lock.lock(); + std::unique_lock 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*/) {