Skip to content

Commit

Permalink
Set context actual domain id (#410)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Santiago Paunovic <ivanpauno@ekumenlabs.com>
  • Loading branch information
ivanpauno authored and ahcorde committed Oct 15, 2020
1 parent 46284d6 commit 5b17bcd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion rmw_fastrtps_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ init_context_impl(rmw_context_t * context)
participant_info(
rmw_fastrtps_shared_cpp::create_participant(
eprosima_fastrtps_identifier,
context->options.domain_id,
context->actual_domain_id,
&context->options.security_options,
(context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0,
context->options.enclave,
Expand Down
6 changes: 3 additions & 3 deletions rmw_fastrtps_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ rmw_init(const rmw_init_options_t * options, rmw_context_t * context)
return RMW_RET_INVALID_ARGUMENT;
}

const rmw_context_t zero_context = rmw_get_zero_initialized_context();
assert(0 == std::memcmp(context, &zero_context, sizeof(rmw_context_t)));
auto restore_context = rcpputils::make_scope_exit(
[context, &zero_context]() {*context = zero_context;});
[context]() {*context = rmw_get_zero_initialized_context();});

context->instance_id = options->instance_id;
context->implementation_identifier = eprosima_fastrtps_identifier;
context->actual_domain_id =
RMW_DEFAULT_DOMAIN_ID == options->domain_id ? 0uL : options->domain_id;

context->impl = new (std::nothrow) rmw_context_impl_t();
if (nullptr == context->impl) {
Expand Down
2 changes: 1 addition & 1 deletion rmw_fastrtps_dynamic_cpp/src/init_rmw_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ init_context_impl(rmw_context_t * context)
participant_info(
rmw_fastrtps_shared_cpp::create_participant(
eprosima_fastrtps_identifier,
context->options.domain_id,
context->actual_domain_id,
&context->options.security_options,
(context->options.localhost_only == RMW_LOCALHOST_ONLY_ENABLED) ? 1 : 0,
context->options.enclave,
Expand Down
6 changes: 3 additions & 3 deletions rmw_fastrtps_dynamic_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ rmw_init(const rmw_init_options_t * options, rmw_context_t * context)
return RMW_RET_INVALID_ARGUMENT;
}

const rmw_context_t zero_context = rmw_get_zero_initialized_context();
assert(0 == std::memcmp(context, &zero_context, sizeof(rmw_context_t)));
auto restore_context = rcpputils::make_scope_exit(
[context, &zero_context]() {*context = zero_context;});
[context]() {*context = rmw_get_zero_initialized_context();});

context->instance_id = options->instance_id;
context->implementation_identifier = eprosima_fastrtps_identifier;
context->actual_domain_id =
RMW_DEFAULT_DOMAIN_ID == options->domain_id ? 0uL : options->domain_id;

context->impl = new (std::nothrow) rmw_context_impl_t();
if (nullptr == context->impl) {
Expand Down
6 changes: 2 additions & 4 deletions rmw_fastrtps_shared_cpp/src/participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ rmw_fastrtps_shared_cpp::create_participant(

// No custom handling of RMW_DEFAULT_DOMAIN_ID. Simply use a reasonable domain id.
#if FASTRTPS_VERSION_MAJOR < 2
participantAttrs.rtps.builtin.domainId =
static_cast<uint32_t>(domain_id != RMW_DEFAULT_DOMAIN_ID ? domain_id : 0u);
participantAttrs.rtps.builtin.domainId = static_cast<uint32_t>(domain_id);
#else
participantAttrs.domainId =
static_cast<uint32_t>(domain_id != RMW_DEFAULT_DOMAIN_ID ? domain_id : 0u);
participantAttrs.domainId = static_cast<uint32_t>(domain_id);
#endif

size_t length = snprintf(nullptr, 0, "enclave=%s;", enclave) + 1;
Expand Down

0 comments on commit 5b17bcd

Please sign in to comment.