From 263963d4e4a369333c53325e16f3b5b4ed508256 Mon Sep 17 00:00:00 2001 From: Miguel Company <MiguelCompany@eprosima.com> Date: Tue, 26 May 2020 18:06:37 +0200 Subject: [PATCH] Addressing review. Signed-off-by: Miguel Company <MiguelCompany@eprosima.com> --- rmw_fastrtps_shared_cpp/src/rmw_response.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rmw_fastrtps_shared_cpp/src/rmw_response.cpp b/rmw_fastrtps_shared_cpp/src/rmw_response.cpp index 9884c6d42..d7eb033c6 100644 --- a/rmw_fastrtps_shared_cpp/src/rmw_response.cpp +++ b/rmw_fastrtps_shared_cpp/src/rmw_response.cpp @@ -104,9 +104,13 @@ __rmw_send_response( wparams.related_sample_identity().sequence_number().low = (int32_t)(request_header->sequence_number & 0xFFFFFFFF); - const eprosima::fastrtps::rtps::GUID_t& related_guid = + // According to the list of possible entity kinds in section 9.3.1.2 of RTPS + // readers will have this bit on, while writers will not. We use this to know + // if the related guid is the request writer or the response reader. + constexpr entity_id_is_reader_bit = 0x04; + const eprosima::fastrtps::rtps::GUID_t & related_guid = wparams.related_sample_identity().writer_guid(); - if( (related_guid.entityId.value[3] & 0x04) != 0) + if((related_guid.entityId.value[3] & entity_id_is_reader_bit) != 0) { // Related guid is a reader, so it is the response subscription guid. // Wait for the response writer to be matched with it.