Skip to content

Commit 7c60d0d

Browse files
Fix domain bug in rmw_init (backport #335) (#338)
Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> Co-authored-by: David Laseca Perez <davidlaseca@eprosima.com>
1 parent efbd887 commit 7c60d0d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎rmw_microxrcedds_c/src/rmw_init.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ rmw_init_options_init(
5353
init_options->implementation_identifier = eprosima_microxrcedds_identifier;
5454
init_options->allocator = allocator;
5555
init_options->enclave = NULL;
56-
init_options->domain_id = 0;
56+
init_options->domain_id = RMW_DEFAULT_DOMAIN_ID;
5757
init_options->security_options = rmw_get_default_security_options();
5858

5959
// This can be call before rmw_init()
@@ -216,7 +216,8 @@ rmw_init(
216216
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
217217
context->instance_id = options->instance_id;
218218
context->implementation_identifier = eprosima_microxrcedds_identifier;
219-
context->actual_domain_id = options->domain_id;
219+
context->actual_domain_id =
220+
(RMW_DEFAULT_DOMAIN_ID == options->domain_id) ? 0u : options->domain_id;
220221

221222
#ifdef UCLIENT_PROFILE_MULTITHREAD
222223
if (!rmw_uxrce_wait_mutex_initialized) {
@@ -377,6 +378,9 @@ rmw_context_fini(
377378
{
378379
rmw_ret_t ret = RMW_RET_OK;
379380

381+
// Safety net against leaks if the app shuts down without destroying its nodes
382+
// Nodes destroyed here make a later rcl_node_fini() return RMW_RET_ERROR, this
383+
// is normally triggered by rclc_support_fini() -> rcl_shutdown() -> rmw_shutdown()
380384
rmw_uxrce_mempool_item_t * item = node_memory.allocateditems;
381385

382386
while (item != NULL) {

0 commit comments

Comments
 (0)