Skip to content

Commit 5dcd5a3

Browse files
Do not crash Executor when send_response fails due to client failure. (ros2#2276) (ros2#2279)
* Do not crash Executor when send_response fails due to client failure. Related to ros2/ros2#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 <[email protected]> * Update rclcpp/include/rclcpp/service.hpp Co-authored-by: Tomoya Fujita <[email protected]> Signed-off-by: Zang MingJie <[email protected]> * address review comments. Signed-off-by: Tomoya Fujita <[email protected]> --------- Signed-off-by: Zang MingJie <[email protected]> Signed-off-by: Tomoya Fujita <[email protected]> Co-authored-by: Zang MingJie <[email protected]> (cherry picked from commit fbe8f28) Co-authored-by: Tomoya Fujita <[email protected]>
1 parent 7b7531b commit 5dcd5a3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

rclcpp/include/rclcpp/service.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ class Service
482482
{
483483
rcl_ret_t ret = rcl_send_response(get_service_handle().get(), &req_id, &response);
484484

485+
if (ret == RCL_RET_TIMEOUT) {
486+
RCLCPP_WARN(
487+
node_logger_.get_child("rclcpp"),
488+
"failed to send response to %s (timeout): %s",
489+
this->get_service_name(), rcl_get_error_string().str);
490+
rcl_reset_error();
491+
return;
492+
}
485493
if (ret != RCL_RET_OK) {
486494
rclcpp::exceptions::throw_from_rcl_error(ret, "failed to send response");
487495
}

0 commit comments

Comments
 (0)