From 059457aad375a3d9422acd1336f2e3e4f55a11c0 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 --- 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 ce1693f50eb..294e78bbc91 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.cpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.cpp @@ -56,18 +56,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*/) {