From 2d158572696105219b0fa162fb1d890528fcbd36 Mon Sep 17 00:00:00 2001 From: Michel Hidalgo Date: Fri, 19 Jun 2020 17:22:16 -0300 Subject: [PATCH] Handle RMW_DEFAULT_DOMAIN_ID. 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 2ad92c37..508512a2 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -925,7 +925,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; } @@ -1114,8 +1117,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;