From a5de541029271aa8d336b1d4909da83ed53860a5 Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Fri, 16 Jun 2023 12:47:24 +0800 Subject: [PATCH 1/3] Do not crash Executor when send_response fails due to client failure. Related to https://github.com/ros2/ros2/issues/1253 It is not sane that a faulty client can crash our service Executor, as discussed in the referred issue, if the client is not setup properly, send_response may return RCL_RET_TIMEOUT, we should not throw an error in this case. Signed-off-by: Zang MingJie --- rclcpp/include/rclcpp/service.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 2ae79a6637..a55e4edb28 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -486,6 +486,14 @@ class Service { rcl_ret_t ret = rcl_send_response(get_service_handle().get(), &req_id, &response); + if (ret == RCL_RET_TIMEOUT) { + RCLCPP_WARN( + rclcpp::get_node_logger(node_handle_.get()).get_child("rclcpp"), + "failed to send response: %s", + rcl_get_error_string().str); + rcl_reset_error(); + return; + } if (ret != RCL_RET_OK) { rclcpp::exceptions::throw_from_rcl_error(ret, "failed to send response"); } From d796a93666a2d8e7255759f4ecbd4d9fbc9e6781 Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Mon, 10 Jul 2023 18:02:18 +0800 Subject: [PATCH 2/3] Update rclcpp/include/rclcpp/service.hpp Co-authored-by: Tomoya Fujita Signed-off-by: Zang MingJie --- rclcpp/include/rclcpp/service.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index a55e4edb28..9bd57400dc 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -489,7 +489,7 @@ class Service if (ret == RCL_RET_TIMEOUT) { RCLCPP_WARN( rclcpp::get_node_logger(node_handle_.get()).get_child("rclcpp"), - "failed to send response: %s", + "failed to send response (timeout): %s", rcl_get_error_string().str); rcl_reset_error(); return; From 60fb512a0ce69a9fbce36128c0989c89f6ee0893 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Wed, 16 Aug 2023 22:43:34 -0700 Subject: [PATCH 3/3] address review comments. Signed-off-by: Tomoya Fujita --- rclcpp/include/rclcpp/service.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 9bd57400dc..9e08dc235d 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -488,9 +488,9 @@ class Service if (ret == RCL_RET_TIMEOUT) { RCLCPP_WARN( - rclcpp::get_node_logger(node_handle_.get()).get_child("rclcpp"), - "failed to send response (timeout): %s", - rcl_get_error_string().str); + node_logger_.get_child("rclcpp"), + "failed to send response to %s (timeout): %s", + this->get_service_name(), rcl_get_error_string().str); rcl_reset_error(); return; }