Closed dzusan closed 1 year ago
Hello @dzusan, sorry if this is not well documented or has examples, but when preparing the buffer the session lock is not unlocked on purpose because after the "buffer preparation" is expected that the user writes the payload in the prepared buffer. So it is the user responsible for unlocking the session.
This is why the session is unlocked only when the buffer prepare fails.
You can see an example of the usage at application level here: https://github.com/micro-ROS/rmw_microxrcedds/blob/bc4eb312ac4601a4137c35f4a56b9b83b4b18339/rmw_microxrcedds_c/src/rmw_publish.c#L76
Oh, thank you @pablogs9 With UXR_UNLOCK_STREAM_ID
in user code it works properly. You can close the PR. But I would like to see a little note about the need to give mutex manually in brief of each function that requires it.
It is only in the buffer preparation methods. We will document it.
Using
uxr_prepare_output_stream()
in two concurrent threads of FreeRTOS beforeuxr_run_session_until_confirm_delivery()
blocks one of the threads forever due thestream_id
not being unlocked after locking. In other words, a recursive mutex is taken and given an unequal number of times.