Skip to content

Commit 5159d71

Browse files
authored
Merge pull request #372 from luca-della-vedova/fix/node_drop_order
Move rcl structs to end of Node declaration
2 parents 62fea75 + 1b75a23 commit 5159d71

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

rclrs/src/node.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ unsafe impl Send for rcl_node_t {}
6565
/// [3]: crate::NodeBuilder::new
6666
/// [4]: crate::NodeBuilder::namespace
6767
pub struct Node {
68-
pub(crate) rcl_node_mtx: Arc<Mutex<rcl_node_t>>,
69-
pub(crate) rcl_context_mtx: Arc<Mutex<rcl_context_t>>,
7068
pub(crate) clients_mtx: Mutex<Vec<Weak<dyn ClientBase>>>,
7169
pub(crate) guard_conditions_mtx: Mutex<Vec<Weak<GuardCondition>>>,
7270
pub(crate) services_mtx: Mutex<Vec<Weak<dyn ServiceBase>>>,
7371
pub(crate) subscriptions_mtx: Mutex<Vec<Weak<dyn SubscriptionBase>>>,
7472
time_source: TimeSource,
7573
parameter: ParameterInterface,
74+
// Note: it's important to have those last since `drop` will be called in order of declaration
75+
// in the struct and both `TimeSource` and `ParameterInterface` contain subscriptions /
76+
// services that will fail to be dropped if the context or node is destroyed first.
77+
pub(crate) rcl_node_mtx: Arc<Mutex<rcl_node_t>>,
78+
pub(crate) rcl_context_mtx: Arc<Mutex<rcl_context_t>>,
7679
}
7780

7881
impl Eq for Node {}

0 commit comments

Comments
 (0)