From d6c2de655fd5914866ba1eea0b69b7ebe5b5b57f Mon Sep 17 00:00:00 2001 From: Mauro Passerino Date: Thu, 24 Aug 2023 13:13:13 +0100 Subject: [PATCH] Do not crash Executor when send_response fails due to client failure https://github.com/ros2/rclcpp/pull/2276/ --- rclcpp/include/rclcpp/service.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rclcpp/include/rclcpp/service.hpp b/rclcpp/include/rclcpp/service.hpp index 40895426db..ce10db5832 100644 --- a/rclcpp/include/rclcpp/service.hpp +++ b/rclcpp/include/rclcpp/service.hpp @@ -555,6 +555,15 @@ class Service { rcl_ret_t ret = rcl_send_response(get_service_handle().get(), &req_id, &response); + if (ret == RCL_RET_TIMEOUT) { + RCLCPP_WARN( + 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; + } + if (ret != RCL_RET_OK) { rclcpp::exceptions::throw_from_rcl_error(ret, "failed to send response"); }