diff --git a/rcl/src/rcl/localhost.c b/rcl/src/rcl/localhost.c index a798c4783..556a07b4a 100644 --- a/rcl/src/rcl/localhost.c +++ b/rcl/src/rcl/localhost.c @@ -41,6 +41,9 @@ rcl_get_localhost_only(rmw_localhost_only_t * localhost_only) get_env_error_str); return RCL_RET_ERROR; } - *localhost_only = ros_local_host_env_val != NULL && strcmp(ros_local_host_env_val, "1") == 0; + *localhost_only = (ros_local_host_env_val != NULL && + strcmp( + ros_local_host_env_val, + "1") == 0) ? RMW_LOCALHOST_ONLY_ENABLED : RMW_LOCALHOST_ONLY_DISABLED; return RCL_RET_OK; } diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 4ae93ecd8..46d248026 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -263,15 +263,12 @@ rcl_node_init( RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Using domain ID of '%zu'", domain_id); node->impl->actual_domain_id = domain_id; - if (RMW_LOCALHOST_ONLY_DEFAULT == localhost_only) { - if (RMW_RET_OK != rcl_get_localhost_only(&localhost_only)) { - goto fail; - } - } + localhost_only = context->impl->init_options.impl->rmw_init_options.localhost_only; node->impl->rmw_node_handle = rmw_create_node( &(node->context->impl->rmw_context), - name, local_namespace_, domain_id, localhost_only); + name, local_namespace_, domain_id, + localhost_only == RMW_LOCALHOST_ONLY_ENABLED); RCL_CHECK_FOR_NULL_WITH_MSG( node->impl->rmw_node_handle, rmw_get_error_string().str, goto fail);