Handle RMW_DEFAULT_DOMAIN_ID. (#194) (#199)

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
This commit is contained in:
Michel Hidalgo 2020-06-23 12:15:22 -03:00 committed by GitHub
parent 64b0f6750c
commit 6598191749
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 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 and tearing down the domain for versions of Cyclone that implement the original
version of dds_create_domain that doesn't return a handle. */ version of dds_create_domain that doesn't return a handle. */
this->domain_id = static_cast<dds_domainid_t>(options->domain_id); this->domain_id = static_cast<dds_domainid_t>(
// 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)) { if (!check_create_domain(this->domain_id, options->localhost_only)) {
return RMW_RET_ERROR; 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, eclipse_cyclonedds_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
/* domain_id = UINT32_MAX = Cyclone DDS' "default domain id".*/ if (options->domain_id >= UINT32_MAX && options->domain_id != RMW_DEFAULT_DOMAIN_ID) {
if (options->domain_id >= UINT32_MAX) {
RCUTILS_LOG_ERROR_NAMED( RCUTILS_LOG_ERROR_NAMED(
"rmw_cyclonedds_cpp", "rmw_create_node: domain id out of range"); "rmw_cyclonedds_cpp", "rmw_create_node: domain id out of range");
return RMW_RET_INVALID_ARGUMENT; return RMW_RET_INVALID_ARGUMENT;