From 3de0cc2b7de2246c9cd7a1778b08c4b73eeea4f7 Mon Sep 17 00:00:00 2001 From: Chen Lihui Date: Tue, 25 Aug 2020 09:53:57 +0800 Subject: [PATCH] [backport foxy] Fix memory leak that wait_set might be not destoryed in some case. (#423) Signed-off-by: Chen.Lihui --- rmw_fastrtps_shared_cpp/src/listener_thread.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/src/listener_thread.cpp b/rmw_fastrtps_shared_cpp/src/listener_thread.cpp index 8df2bb70b..50be5b3da 100644 --- a/rmw_fastrtps_shared_cpp/src/listener_thread.cpp +++ b/rmw_fastrtps_shared_cpp/src/listener_thread.cpp @@ -144,6 +144,11 @@ node_listener(rmw_context_t * context) { TERMINATE_THREAD("rmw_wait failed"); } + if (RMW_RET_OK != rmw_fastrtps_shared_cpp::__rmw_destroy_wait_set( + context->implementation_identifier, wait_set)) + { + TERMINATE_THREAD("failed to destroy wait set"); + } if (subscriptions_buffer[0]) { rmw_dds_common::msg::ParticipantEntitiesInfo msg; bool taken; @@ -168,10 +173,5 @@ node_listener(rmw_context_t * context) common_context->graph_cache.update_participant_entities(msg); } } - if (RMW_RET_OK != rmw_fastrtps_shared_cpp::__rmw_destroy_wait_set( - context->implementation_identifier, wait_set)) - { - TERMINATE_THREAD("failed to destroy wait set"); - } } }