diff --git a/rclrs/src/node.rs b/rclrs/src/node.rs index f1792c1e6..87702ab0f 100644 --- a/rclrs/src/node.rs +++ b/rclrs/src/node.rs @@ -65,14 +65,17 @@ unsafe impl Send for rcl_node_t {} /// [3]: crate::NodeBuilder::new /// [4]: crate::NodeBuilder::namespace pub struct Node { - pub(crate) rcl_node_mtx: Arc>, - pub(crate) rcl_context_mtx: Arc>, pub(crate) clients_mtx: Mutex>>, pub(crate) guard_conditions_mtx: Mutex>>, pub(crate) services_mtx: Mutex>>, pub(crate) subscriptions_mtx: Mutex>>, time_source: TimeSource, parameter: ParameterInterface, + // Note: it's important to have those last since `drop` will be called in order of declaration + // in the struct and both `TimeSource` and `ParameterInterface` contain subscriptions / + // services that will fail to be dropped if the context or node is destroyed first. + pub(crate) rcl_node_mtx: Arc>, + pub(crate) rcl_context_mtx: Arc>, } impl Eq for Node {}