File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ rmw_ret_t rmw_uros_ping_agent(
3333{
3434 bool success = false;
3535
36+ UXR_LOCK (& session_memory .mutex );
37+
3638 if (NULL == session_memory .allocateditems ) {
3739#ifdef RMW_UXRCE_TRANSPORT_SERIAL
3840 uxrSerialTransport transport ;
@@ -52,6 +54,7 @@ rmw_ret_t rmw_uros_ping_agent(
5254 rmw_ret_t ret = rmw_uxrce_transport_init (NULL , NULL , (void * )& transport );
5355
5456 if (RMW_RET_OK != ret ) {
57+ UXR_UNLOCK (& session_memory .mutex );
5558 return ret ;
5659 }
5760
@@ -67,6 +70,8 @@ rmw_ret_t rmw_uros_ping_agent(
6770 } while (NULL != item && !success );
6871 }
6972
73+ UXR_UNLOCK (& session_memory .mutex );
74+
7075 return success ? RMW_RET_OK : RMW_RET_ERROR ;
7176}
7277
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ bool rmw_uros_epoch_synchronized()
3030 rmw_uxrce_mempool_item_t * item = session_memory .allocateditems ;
3131 rmw_context_impl_t * context = (rmw_context_impl_t * )item -> data ;
3232
33- return context -> session .synchronized ;
33+ bool ret = context -> session .synchronized ;
34+ return ret ;
3435}
3536
3637int64_t rmw_uros_epoch_millis ()
@@ -44,7 +45,8 @@ int64_t rmw_uros_epoch_millis()
4445 rmw_uxrce_mempool_item_t * item = session_memory .allocateditems ;
4546 rmw_context_impl_t * context = (rmw_context_impl_t * )item -> data ;
4647
47- return uxr_epoch_millis (& context -> session );
48+ int64_t ret = uxr_epoch_millis (& context -> session );
49+ return ret ;
4850}
4951
5052int64_t rmw_uros_epoch_nanos ()
@@ -58,7 +60,8 @@ int64_t rmw_uros_epoch_nanos()
5860 rmw_uxrce_mempool_item_t * item = session_memory .allocateditems ;
5961 rmw_context_impl_t * context = (rmw_context_impl_t * )item -> data ;
6062
61- return uxr_epoch_nanos (& context -> session );
63+ int64_t ret = uxr_epoch_nanos (& context -> session );
64+ return ret ;
6265}
6366
6467rmw_ret_t rmw_uros_sync_session (
@@ -77,8 +80,7 @@ rmw_ret_t rmw_uros_sync_session(
7780
7881 if (!uxr_sync_session (& context -> session , timeout_ms )) {
7982 RMW_SET_ERROR_MSG ("Time synchronization failed." );
80- return RMW_RET_ERROR ;
83+ ret = RMW_RET_ERROR ;
8184 }
82-
8385 return ret ;
8486}
Original file line number Diff line number Diff line change @@ -51,13 +51,12 @@ rmw_wait(
5151 timeout .i32 = (timeout .i64 > INT32_MAX ) ? INT32_MAX : timeout .i64 ;
5252 }
5353
54- // Clean expired buffers
5554 rmw_uxrce_clean_expired_static_input_buffer ();
5655
57- rmw_uxrce_mempool_item_t * item = NULL ;
56+ UXR_LOCK ( & session_memory . mutex ) ;
5857
5958 // Clear run flag for all sessions
60- item = session_memory .allocateditems ;
59+ rmw_uxrce_mempool_item_t * item = session_memory .allocateditems ;
6160 while (item != NULL ) {
6261 rmw_context_impl_t * custom_context = (rmw_context_impl_t * )item -> data ;
6362 custom_context -> need_to_be_ran = false;
@@ -90,7 +89,11 @@ rmw_wait(
9089 item = item -> next ;
9190 }
9291
93- rmw_uxrce_clean_expired_static_input_buffer ();
92+ // There is no context that contais any of the wait set entities. Nothing to wait here.
93+ if (available_contexts == 0 ) {
94+ UXR_UNLOCK (& session_memory .mutex );
95+ return RMW_RET_OK ;
96+ }
9497
9598 int32_t per_session_timeout =
9699 (timeout .i32 == UXR_TIMEOUT_INF ) ? UXR_TIMEOUT_INF :
@@ -105,6 +108,8 @@ rmw_wait(
105108 item = item -> next ;
106109 }
107110
111+ UXR_UNLOCK (& session_memory .mutex );
112+
108113 bool buffered_status = false;
109114
110115 // Check services
Original file line number Diff line number Diff line change @@ -224,9 +224,10 @@ size_t rmw_uxrce_count_static_input_buffer_for_entity(
224224 void * entity )
225225{
226226 size_t count = 0 ;
227- rmw_uxrce_mempool_item_t * item = static_buffer_memory .allocateditems ;
228227
229228 UXR_LOCK (& static_buffer_memory .mutex );
229+ rmw_uxrce_mempool_item_t * item = static_buffer_memory .allocateditems ;
230+
230231 while (item != NULL ) {
231232 rmw_uxrce_static_input_buffer_t * data = (rmw_uxrce_static_input_buffer_t * )item -> data ;
232233 if (data -> owner == entity ) {
You can’t perform that action at this time.
0 commit comments