Skip to content

Commit 90f1a72

Browse files
authored
Fix service locks (#132)
1 parent fb0c24e commit 90f1a72

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

rmw_microxrcedds_c/src/rmw_request.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ rmw_send_request(
4848
custom_client->stream_id, custom_client->client_id, &mb,
4949
request_length);
5050

51-
functions->cdr_serialize(ros_request, &mb);
52-
53-
UXR_UNLOCK_STREAM_ID(&custom_node->context->session, custom_client->stream_id);
54-
5551
if (UXR_INVALID_REQUEST_ID == *sequence_id)
5652
{
5753
RMW_SET_ERROR_MSG("Micro XRCE-DDS service request error.");
5854
return RMW_RET_ERROR;
5955
}
6056

57+
functions->cdr_serialize(ros_request, &mb);
58+
59+
UXR_UNLOCK_STREAM_ID(&custom_node->context->session, custom_client->stream_id);
60+
6161
if (UXR_BEST_EFFORT_STREAM == custom_client->stream_id.type)
6262
{
6363
uxr_flash_output_streams(&custom_node->context->session);

rmw_microxrcedds_c/src/rmw_response.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,25 @@ rmw_send_response(
6060
custom_service->stream_id, custom_service->service_id, &mb,
6161
response_length);
6262

63+
if (UXR_INVALID_REQUEST_ID == rc)
64+
{
65+
RMW_SET_ERROR_MSG("Micro XRCE-DDS service response error.");
66+
return RMW_RET_ERROR;
67+
}
68+
6369
uxr_serialize_SampleIdentity(&mb, &sample_id);
6470
functions->cdr_serialize(ros_response, &mb);
6571

6672
UXR_UNLOCK_STREAM_ID(&custom_node->context->session, custom_service->stream_id);
6773

68-
if (UXR_INVALID_REQUEST_ID == rc)
74+
if (UXR_BEST_EFFORT_STREAM == custom_service->stream_id.type)
6975
{
70-
RMW_SET_ERROR_MSG("Micro XRCE-DDS service response error.");
71-
return RMW_RET_ERROR;
76+
uxr_flash_output_streams(&custom_node->context->session);
77+
}
78+
else
79+
{
80+
uxr_run_session_until_confirm_delivery(
81+
&custom_node->context->session, RMW_UXRCE_PUBLISH_RELIABLE_TIMEOUT);
7282
}
7383

7484
return RMW_RET_OK;

0 commit comments

Comments
 (0)