Skip to content

Commit

Permalink
Use DataWriter Qos to configure max_blocking_time on rmw_send_response (
Browse files Browse the repository at this point in the history
#704)

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany authored Aug 21, 2023
1 parent 88bef2e commit c49991e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ class ServicePubListener : public eprosima::fastdds::dds::DataWriterListener
return cv_.wait_for(lock, rel_time, guid_is_present);
}

template<class Rep, class Period>
client_present_t
check_for_subscription(
const eprosima::fastrtps::rtps::GUID_t & guid)
const eprosima::fastrtps::rtps::GUID_t & guid,
const std::chrono::duration<Rep, Period> & max_blocking_time)
{
{
std::lock_guard<std::mutex> lock(mutex_);
Expand All @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion rmw_fastrtps_shared_cpp/src/rmw_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c49991e

Please sign in to comment.