From 14dd88136c9fcf9cf0392d764e146f8e5f8f5a18 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Tue, 28 Jul 2020 17:22:51 -0700 Subject: [PATCH] Tweaks to client.c and subscription.c for cleaner init/fini Signed-off-by: Stephen Brawner --- rcl/src/rcl/client.c | 2 ++ rcl/src/rcl/publisher.c | 1 + rcl/src/rcl/service.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/rcl/src/rcl/client.c b/rcl/src/rcl/client.c index 9bf70dc4a..6a6a51001 100644 --- a/rcl/src/rcl/client.c +++ b/rcl/src/rcl/client.c @@ -189,6 +189,7 @@ rcl_client_init( fail: if (client->impl) { allocator->deallocate(client->impl, allocator->state); + client->impl = NULL; } ret = fail_ret; // Fall through to cleanup @@ -223,6 +224,7 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node) result = RCL_RET_ERROR; } allocator.deallocate(client->impl, allocator.state); + client->impl = NULL; } RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Client finalized"); return result; diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index b82208a6b..eb2cc90bd 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -236,6 +236,7 @@ rcl_publisher_fini(rcl_publisher_t * publisher, rcl_node_t * node) result = RCL_RET_ERROR; } allocator.deallocate(publisher->impl, allocator.state); + publisher->impl = NULL; } RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Publisher finalized"); return result; diff --git a/rcl/src/rcl/service.c b/rcl/src/rcl/service.c index 6dc1c79fc..cf7de3c4e 100644 --- a/rcl/src/rcl/service.c +++ b/rcl/src/rcl/service.c @@ -193,6 +193,7 @@ rcl_service_init( fail: if (service->impl) { allocator->deallocate(service->impl, allocator->state); + service->impl = NULL; } ret = fail_ret; // Fall through to clean up @@ -228,6 +229,7 @@ rcl_service_fini(rcl_service_t * service, rcl_node_t * node) result = RCL_RET_ERROR; } allocator.deallocate(service->impl, allocator.state); + service->impl = NULL; } RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Service finalized"); return result;