Skip to content

Commit 9754467

Browse files
committed
Fixes service_info
Signed-off-by: Minju, Lee <dlalswn531@naver.com>
1 parent 9b89c9c commit 9754467

File tree

1 file changed

+6
-166
lines changed

1 file changed

+6
-166
lines changed

rmw_cyclonedds_cpp/src/rmw_node.cpp

+6-166
Original file line numberDiff line numberDiff line change
@@ -5855,99 +5855,18 @@ extern "C" rmw_ret_t rmw_get_clients_info_by_service(
58555855
return RMW_RET_INVALID_ARGUMENT;
58565856
}
58575857
auto common_context = &node->context->impl->common;
5858-
std::string mangled_rq_topic_name, mangled_rp_topic_name;
5859-
mangled_rq_topic_name = mangled_rp_topic_name = service_name;
5858+
std::string mangled_rp_topic_name = service_name;
58605859
DemangleFunction demangle_type = _identity_demangle;
58615860
if (!no_mangle) {
5862-
mangled_rq_topic_name = \
5863-
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", false);
58645861
mangled_rp_topic_name = \
58655862
make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", false);
58665863
demangle_type = _demangle_if_ros_type;
58675864
}
5868-
5869-
rmw_topic_endpoint_info_array_t publishers_info = \
5870-
rmw_get_zero_initialized_topic_endpoint_info_array();
5871-
rmw_ret_t ret = common_context->graph_cache.get_writers_info_by_topic(
5872-
mangled_rq_topic_name,
5873-
demangle_type,
5874-
allocator,
5875-
&publishers_info);
5876-
std::unique_ptr<
5877-
rmw_topic_endpoint_info_array_t,
5878-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
5879-
publishers_info_delete_on_error(
5880-
&publishers_info,
5881-
[allocator](rmw_topic_endpoint_info_array_t * p) {
5882-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
5883-
p,
5884-
allocator
5885-
);
5886-
if (RMW_RET_OK != ret) {
5887-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy publishers_info when function failed.");
5888-
}
5889-
}
5890-
);
5891-
if (RMW_RET_OK != ret) {
5892-
return ret;
5893-
}
5894-
5895-
rmw_topic_endpoint_info_array_t subscriptions_info = \
5896-
rmw_get_zero_initialized_topic_endpoint_info_array();
5897-
ret = common_context->graph_cache.get_readers_info_by_topic(
5865+
return common_context->graph_cache.get_readers_info_by_topic(
58985866
mangled_rp_topic_name,
58995867
demangle_type,
59005868
allocator,
5901-
&subscriptions_info);
5902-
std::unique_ptr<
5903-
rmw_topic_endpoint_info_array_t,
5904-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
5905-
subscriptions_info_delete_on_error(
5906-
&subscriptions_info,
5907-
[allocator](rmw_topic_endpoint_info_array_t * p) {
5908-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
5909-
p,
5910-
allocator
5911-
);
5912-
if (RMW_RET_OK != ret) {
5913-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy subscriptions_info when function failed.");
5914-
}
5915-
}
5916-
);
5917-
if (RMW_RET_OK != ret) {
5918-
return ret;
5919-
}
5920-
5921-
size_t total_size = publishers_info.size + subscriptions_info.size;
5922-
ret = rmw_topic_endpoint_info_array_init_with_size(clients_info, total_size, allocator);
5923-
std::unique_ptr<
5924-
rmw_topic_endpoint_info_array_t,
5925-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
5926-
clients_info_delete_on_error(
5927-
clients_info,
5928-
[allocator](rmw_topic_endpoint_info_array_t * p) {
5929-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
5930-
p,
5931-
allocator
5932-
);
5933-
if (RMW_RET_OK != ret) {
5934-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy clients_info when function failed.");
5935-
}
5936-
}
5937-
);
5938-
if (RMW_RET_OK != ret) {
5939-
return ret;
5940-
}
5941-
for (size_t i = 0; i < publishers_info.size; ++i) {
5942-
clients_info->info_array[i] = publishers_info.info_array[i];
5943-
}
5944-
for (size_t i = 0; i < subscriptions_info.size; ++i) {
5945-
clients_info->info_array[publishers_info.size + i] = subscriptions_info.info_array[i];
5946-
}
5947-
publishers_info_delete_on_error.release();
5948-
subscriptions_info_delete_on_error.release();
5949-
clients_info_delete_on_error.release();
5950-
return RMW_RET_OK;
5869+
clients_info);
59515870
}
59525871

59535872
extern "C" rmw_ret_t rmw_get_servers_info_by_service(
@@ -5970,97 +5889,18 @@ extern "C" rmw_ret_t rmw_get_servers_info_by_service(
59705889

59715890
auto common_context = &node->context->impl->common;
59725891

5973-
std::string mangled_rq_topic_name, mangled_rp_topic_name;
5974-
mangled_rq_topic_name = mangled_rp_topic_name = service_name;
5892+
std::string mangled_rp_topic_name = service_name;
59755893
DemangleFunction demangle_type = _identity_demangle;
59765894
if (!no_mangle) {
5977-
mangled_rq_topic_name = \
5978-
make_fqtopic(ROS_SERVICE_REQUESTER_PREFIX, service_name, "Request", false);
59795895
mangled_rp_topic_name = \
59805896
make_fqtopic(ROS_SERVICE_RESPONSE_PREFIX, service_name, "Reply", false);
59815897
demangle_type = _demangle_if_ros_type;
59825898
}
5983-
rmw_topic_endpoint_info_array_t subscriptions_info = \
5984-
rmw_get_zero_initialized_topic_endpoint_info_array();
5985-
rmw_ret_t ret = common_context->graph_cache.get_readers_info_by_topic(
5986-
mangled_rq_topic_name,
5987-
demangle_type,
5988-
allocator,
5989-
&subscriptions_info);
5990-
std::unique_ptr<
5991-
rmw_topic_endpoint_info_array_t,
5992-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
5993-
subscriptions_info_delete_on_error(
5994-
&subscriptions_info,
5995-
[allocator](rmw_topic_endpoint_info_array_t * p) {
5996-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
5997-
p,
5998-
allocator
5999-
);
6000-
if (RMW_RET_OK != ret) {
6001-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy subscriptions_info when function failed.");
6002-
}
6003-
}
6004-
);
6005-
if (RMW_RET_OK != ret) {
6006-
return ret;
6007-
}
6008-
rmw_topic_endpoint_info_array_t publishers_info = \
6009-
rmw_get_zero_initialized_topic_endpoint_info_array();
6010-
ret = common_context->graph_cache.get_writers_info_by_topic(
5899+
return common_context->graph_cache.get_writers_info_by_topic(
60115900
mangled_rp_topic_name,
60125901
demangle_type,
60135902
allocator,
6014-
&publishers_info);
6015-
std::unique_ptr<
6016-
rmw_topic_endpoint_info_array_t,
6017-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
6018-
publishers_info_delete_on_error(
6019-
&publishers_info,
6020-
[allocator](rmw_topic_endpoint_info_array_t * p) {
6021-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
6022-
p,
6023-
allocator
6024-
);
6025-
if (RMW_RET_OK != ret) {
6026-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy publishers_info when function failed.");
6027-
}
6028-
}
6029-
);
6030-
if (RMW_RET_OK != ret) {
6031-
return ret;
6032-
}
6033-
6034-
size_t total_size = publishers_info.size + subscriptions_info.size;
6035-
ret = rmw_topic_endpoint_info_array_init_with_size(servers_info, total_size, allocator);
6036-
std::unique_ptr<
6037-
rmw_topic_endpoint_info_array_t,
6038-
std::function<void(rmw_topic_endpoint_info_array_t *)>>
6039-
servers_info_delete_on_error(
6040-
servers_info,
6041-
[allocator](rmw_topic_endpoint_info_array_t * p) {
6042-
rmw_ret_t ret = rmw_topic_endpoint_info_array_fini(
6043-
p,
6044-
allocator
6045-
);
6046-
if (RMW_RET_OK != ret) {
6047-
RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to destroy servers_info when function failed.");
6048-
}
6049-
}
6050-
);
6051-
if (RMW_RET_OK != ret) {
6052-
return ret;
6053-
}
6054-
for (size_t i = 0; i < publishers_info.size; ++i) {
6055-
servers_info->info_array[i] = publishers_info.info_array[i];
6056-
}
6057-
for (size_t i = 0; i < subscriptions_info.size; ++i) {
6058-
servers_info->info_array[publishers_info.size + i] = subscriptions_info.info_array[i];
6059-
}
6060-
publishers_info_delete_on_error.release();
6061-
subscriptions_info_delete_on_error.release();
6062-
servers_info_delete_on_error.release();
6063-
return RMW_RET_OK;
5903+
servers_info);
60645904
}
60655905

60665906
extern "C" rmw_ret_t rmw_qos_profile_check_compatible(

0 commit comments

Comments
 (0)