From 775203b4009cd3ac35b361412451ff12e64c734d Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Mon, 22 Jun 2020 12:08:16 -0300 Subject: [PATCH] Handle RMW_DEFAULT_DOMAIN_ID. (#194) Signed-off-by: Michel Hidalgo --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index fe64263b..4b39ed7a 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -891,7 +891,10 @@ rmw_context_impl_t::init(rmw_init_options_t * options) failed: otherwise there is a race with rmw_destroy_node deleting the last participant and tearing down the domain for versions of Cyclone that implement the original version of dds_create_domain that doesn't return a handle. */ - this->domain_id = static_cast(options->domain_id); + this->domain_id = static_cast( + // No custom handling of RMW_DEFAULT_DOMAIN_ID. Simply use a reasonable domain id. + options->domain_id != RMW_DEFAULT_DOMAIN_ID ? options->domain_id : 0u); + if (!check_create_domain(this->domain_id, options->localhost_only)) { return RMW_RET_ERROR; } @@ -1079,8 +1082,7 @@ extern "C" rmw_ret_t rmw_init(const rmw_init_options_t * options, rmw_context_t eclipse_cyclonedds_identifier, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); - /* domain_id = UINT32_MAX = Cyclone DDS' "default domain id".*/ - if (options->domain_id >= UINT32_MAX) { + if (options->domain_id >= UINT32_MAX && options->domain_id != RMW_DEFAULT_DOMAIN_ID) { RCUTILS_LOG_ERROR_NAMED( "rmw_cyclonedds_cpp", "rmw_create_node: domain id out of range"); return RMW_RET_INVALID_ARGUMENT;