From bcbbdade4a74b249d910a138228b23cce3c4d39a Mon Sep 17 00:00:00 2001 From: Barry Xu Date: Mon, 3 Apr 2023 14:27:05 +0800 Subject: [PATCH] Fix repeated matched event notification Signed-off-by: Barry Xu --- rmw_fastrtps_shared_cpp/src/rmw_wait.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp index 4f18281de..e391287a8 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp @@ -201,6 +201,17 @@ __rmw_wait( if (guard_condition.get_trigger_value()) { active = true; guard_condition.set_trigger_value(false); + } else { + switch (event->event_type) { + // Both a listener and a WaitSet for the same communication status, there are + // 2 triggers. Avoid repeated notification, filter it based trigger value. + case RMW_EVENT_SUBSCRIPTION_MATCHED: + case RMW_EVENT_PUBLICATION_MATCHED: + active = false; + break; + default: + break; + } } }