From 87b4a557d9941b4cce9c467915a80f5ce8a92f6a Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 8 Jul 2026 14:19:24 +0200 Subject: [PATCH 1/3] fix: Fix race condition when untriggering guard conditions. Signed-off-by: Miguel Company --- rmw_fastrtps_shared_cpp/src/rmw_wait.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp index 9f05e50c5..4ef5cad52 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp @@ -328,7 +328,9 @@ __rmw_wait( if (!condition->get_trigger_value()) { guard_conditions->guard_conditions[i] = 0; } - condition->set_trigger_value(false); + else { + condition->set_trigger_value(false); + } } } From bd2cabd67f0464c1785d1223457041afb4cace91 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 8 Jul 2026 14:23:33 +0200 Subject: [PATCH 2/3] fix: return `RMW_RET_OK` whenever an active element is returned Signed-off-by: Miguel Company --- rmw_fastrtps_shared_cpp/src/rmw_wait.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp index 4ef5cad52..59e91d076 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp @@ -255,6 +255,10 @@ __rmw_wait( if (!has_data) { subscriptions->subscribers[i] = 0; } + else { + // We are returning a ready subscription, so we need to indicate that the wait was successful. + wait_result = true; + } } } @@ -269,6 +273,10 @@ __rmw_wait( { clients->clients[i] = 0; } + else { + // We are returning a ready client, so we need to indicate that the wait was successful. + wait_result = true; + } } } @@ -283,6 +291,10 @@ __rmw_wait( { services->services[i] = 0; } + else { + // We are returning a ready service, so we need to indicate that the wait was successful. + wait_result = true; + } } } @@ -318,6 +330,10 @@ __rmw_wait( if (!active) { events->events[i] = 0; } + else { + // We are returning a ready event, so we need to indicate that the wait was successful. + wait_result = true; + } } } @@ -330,6 +346,8 @@ __rmw_wait( } else { condition->set_trigger_value(false); + // We are returning a ready guard condition, so we need to indicate that the wait was successful. + wait_result = true; } } } From 2fa9876fd07c29a024b72e571bebb607c2814985 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 8 Jul 2026 16:25:27 +0200 Subject: [PATCH 3/3] style: uncrustify Signed-off-by: Miguel Company --- rmw_fastrtps_shared_cpp/src/rmw_wait.cpp | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp index 59e91d076..a934a7dfb 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_wait.cpp @@ -254,9 +254,9 @@ __rmw_wait( } if (!has_data) { subscriptions->subscribers[i] = 0; - } - else { - // We are returning a ready subscription, so we need to indicate that the wait was successful. + } else { + // We are returning a ready subscription, + // so we need to indicate that the wait was successful. wait_result = true; } } @@ -272,9 +272,9 @@ __rmw_wait( custom_client_info->response_reader_->get_first_untaken_info(&sample_info)) { clients->clients[i] = 0; - } - else { - // We are returning a ready client, so we need to indicate that the wait was successful. + } else { + // We are returning a ready client, + // so we need to indicate that the wait was successful. wait_result = true; } } @@ -290,9 +290,9 @@ __rmw_wait( custom_service_info->request_reader_->get_first_untaken_info(&sample_info)) { services->services[i] = 0; - } - else { - // We are returning a ready service, so we need to indicate that the wait was successful. + } else { + // We are returning a ready service, + // so we need to indicate that the wait was successful. wait_result = true; } } @@ -329,9 +329,9 @@ __rmw_wait( if (!active) { events->events[i] = 0; - } - else { - // We are returning a ready event, so we need to indicate that the wait was successful. + } else { + // We are returning a ready event, + // so we need to indicate that the wait was successful. wait_result = true; } } @@ -343,10 +343,10 @@ __rmw_wait( auto condition = static_cast(data); if (!condition->get_trigger_value()) { guard_conditions->guard_conditions[i] = 0; - } - else { + } else { condition->set_trigger_value(false); - // We are returning a ready guard condition, so we need to indicate that the wait was successful. + // We are returning a ready guard condition, + // so we need to indicate that the wait was successful. wait_result = true; } }