From d328fd5c9caefe594d4c4bab7f6f5d321a723bfc Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 27 Jun 2022 14:19:23 +0200 Subject: [PATCH] Take all available samples on service/client on_data_available. (#616) Signed-off-by: Miguel Company (cherry picked from commit e9abdc4c28aa12269dfc76986ff0cda81b64f00e) --- .../include/rmw_fastrtps_shared_cpp/custom_client_info.hpp | 2 +- .../include/rmw_fastrtps_shared_cpp/custom_service_info.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp index dad3c01e3..e8677ca71 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_client_info.hpp @@ -96,7 +96,7 @@ class ClientListener : public eprosima::fastdds::dds::DataReaderListener data.is_cdr_buffer = true; data.data = response.buffer_.get(); data.impl = nullptr; // not used when is_cdr_buffer is true - if (reader->take_next_sample(&data, &response.sample_info_) == ReturnCode_t::RETCODE_OK) { + while (reader->take_next_sample(&data, &response.sample_info_) == ReturnCode_t::RETCODE_OK) { if (response.sample_info_.valid_data) { response.sample_identity_ = response.sample_info_.related_sample_identity; diff --git a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp index f66cbdf60..a91dac55f 100644 --- a/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp +++ b/rmw_fastrtps_shared_cpp/include/rmw_fastrtps_shared_cpp/custom_service_info.hpp @@ -209,7 +209,7 @@ class ServiceListener : public eprosima::fastdds::dds::DataReaderListener data.is_cdr_buffer = true; data.data = request.buffer_; data.impl = nullptr; // not used when is_cdr_buffer is true - if (reader->take_next_sample(&data, &request.sample_info_) == ReturnCode_t::RETCODE_OK) { + while (reader->take_next_sample(&data, &request.sample_info_) == ReturnCode_t::RETCODE_OK) { if (request.sample_info_.valid_data) { request.sample_identity_ = request.sample_info_.sample_identity; // Use response subscriber guid (on related_sample_identity) when present.