Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved in pub, sub, client, service, when run_xrce_session fails, get… #265

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rmw_microxrcedds_c/src/rmw_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ rmw_create_client(
custom_node->context, custom_node->context->creation_stream, client_req,
custom_node->context->creation_timeout))
{
put_memory(&client_memory, &custom_client->mem);
goto fail;
}

Expand Down
13 changes: 8 additions & 5 deletions rmw_microxrcedds_c/src/rmw_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ rmw_create_publisher(
const rmw_publisher_options_t * publisher_options)
{
(void)publisher_options;

rmw_uxrce_publisher_t *publisher_data = NULL;
rmw_publisher_t * rmw_publisher = NULL;
if (!node) {
RMW_UROS_TRACE_MESSAGE("node handle is null")
Expand Down Expand Up @@ -112,6 +112,8 @@ rmw_create_publisher(
custom_publisher->cs_cb_size = NULL;
custom_publisher->cs_cb_serialization = NULL;

rmw_publisher->data = custom_publisher;

const rosidl_message_type_support_t * type_support_xrce = NULL;
#ifdef ROSIDL_TYPESUPPORT_MICROXRCEDDS_C__IDENTIFIER_VALUE
type_support_xrce = get_message_typesupport_handle(
Expand Down Expand Up @@ -171,12 +173,9 @@ rmw_create_publisher(
custom_node->context, custom_node->context->creation_stream, publisher_req,
custom_node->context->creation_timeout))
{
put_memory(&publisher_memory, &custom_publisher->mem);
goto fail;
}

rmw_publisher->data = custom_publisher;

// Create datawriter
custom_publisher->datawriter_id = uxr_object_id(
custom_node->context->id_datawriter++,
Expand Down Expand Up @@ -212,13 +211,17 @@ rmw_create_publisher(
custom_node->context, custom_node->context->creation_stream, datawriter_req,
custom_node->context->creation_timeout))
{
put_memory(&publisher_memory, &custom_publisher->mem);
goto fail;
}
}

return rmw_publisher;
fail:
publisher_data = (rmw_uxrce_publisher_t *)rmw_publisher->data;
if (publisher_data != NULL && publisher_data->topic != NULL)
{
rmw_uxrce_fini_topic_memory(publisher_data->topic);
}
rmw_uxrce_fini_publisher_memory(rmw_publisher);
rmw_publisher = NULL;
return rmw_publisher;
Expand Down
1 change: 0 additions & 1 deletion rmw_microxrcedds_c/src/rmw_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ rmw_create_service(
custom_node->context->creation_timeout))
{
RMW_UROS_TRACE_MESSAGE("Issues creating Micro XRCE-DDS entities")
put_memory(&service_memory, &custom_service->mem);
goto fail;
}

Expand Down
14 changes: 8 additions & 6 deletions rmw_microxrcedds_c/src/rmw_subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ rmw_create_subscription(
const rmw_subscription_options_t * subscription_options)
{
(void)subscription_options;

rmw_uxrce_subscription_t *subscription_data = NULL;
rmw_subscription_t * rmw_subscription = NULL;
if (!node) {
RMW_UROS_TRACE_MESSAGE("node handle is null")
Expand Down Expand Up @@ -103,6 +103,8 @@ rmw_create_subscription(
custom_subscription->owner_node = custom_node;
custom_subscription->qos = *qos_policies;

rmw_subscription->data = custom_subscription;

const rosidl_message_type_support_t * type_support_xrce = NULL;
#ifdef ROSIDL_TYPESUPPORT_MICROXRCEDDS_C__IDENTIFIER_VALUE
type_support_xrce = get_message_typesupport_handle(
Expand Down Expand Up @@ -159,7 +161,6 @@ rmw_create_subscription(
custom_node->context, custom_node->context->creation_stream, subscriber_req,
custom_node->context->creation_timeout))
{
put_memory(&subscription_memory, &custom_subscription->mem);
goto fail;
}

Expand Down Expand Up @@ -198,12 +199,8 @@ rmw_create_subscription(
custom_node->context->creation_timeout))
{
RMW_UROS_TRACE_MESSAGE("Issues creating Micro XRCE-DDS entities")
put_memory(&subscription_memory, &custom_subscription->mem);
goto fail;
}

rmw_subscription->data = custom_subscription;

uxrDeliveryControl delivery_control;
delivery_control.max_samples = UXR_MAX_SAMPLES_UNLIMITED;
delivery_control.min_pace_period = 0;
Expand All @@ -223,6 +220,11 @@ rmw_create_subscription(
return rmw_subscription;

fail:
subscription_data = (rmw_uxrce_subscription_t *)rmw_subscription->data;
if ((subscription_data != NULL) && (subscription_data->topic != NULL))
{
rmw_uxrce_fini_topic_memory(subscription_data->topic);
}
rmw_uxrce_fini_subscription_memory(rmw_subscription);
rmw_subscription = NULL;
return rmw_subscription;
Expand Down