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 4162a6409..a461c9417 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 @@ -138,9 +138,11 @@ class ServicePubListener : public eprosima::fastdds::dds::DataWriterListener return cv_.wait_for(lock, rel_time, guid_is_present); } + template client_present_t check_for_subscription( - const eprosima::fastrtps::rtps::GUID_t & guid) + const eprosima::fastrtps::rtps::GUID_t & guid, + const std::chrono::duration & max_blocking_time) { { std::lock_guard lock(mutex_); @@ -151,7 +153,7 @@ class ServicePubListener : public eprosima::fastdds::dds::DataWriterListener } } // Wait for subscription - if (!wait_for_subscription(guid, std::chrono::milliseconds(100))) { + if (!wait_for_subscription(guid, max_blocking_time)) { return client_present_t::MAYBE; } return client_present_t::YES; diff --git a/rmw_fastrtps_shared_cpp/src/rmw_response.cpp b/rmw_fastrtps_shared_cpp/src/rmw_response.cpp index 4d6869906..b016d709f 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_response.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_response.cpp @@ -142,7 +142,12 @@ __rmw_send_response( // Related guid is a reader, so it is the response subscription guid. // Wait for the response writer to be matched with it. auto listener = info->pub_listener_; - client_present_t ret = listener->check_for_subscription(related_guid); + auto writer_max_blocking_time = + info->response_writer_->get_qos().reliability().max_blocking_time; + auto max_blocking_time = + std::chrono::seconds(writer_max_blocking_time.seconds) + + std::chrono::nanoseconds(writer_max_blocking_time.nanosec); + client_present_t ret = listener->check_for_subscription(related_guid, max_blocking_time); if (ret == client_present_t::GONE) { return RMW_RET_OK; } else if (ret == client_present_t::MAYBE) {