Skip to content

Commit 09d72e7

Browse files
mergify[bot]SteveMacenskiclaude[bot]
authored
Fix lifecycle manager deadlock during shutdown (#5438) (#5440)
* Fix lifecycle manager deadlock during shutdown Add stop() method to ServiceClient that cancels internal executor operations and call it in LifecycleServiceClient destructor to prevent deadlock when CTRL+C is pressed during lifecycle node bringup. This addresses issue #5437 where spin_until_future_complete can hang indefinitely during shutdown when bringup and shutdown sequences run concurrently. * Update service_client.hpp --------- (cherry picked from commit f7b6654) Signed-off-by: Steve Macenski <[email protected]> Co-authored-by: Steve Macenski <[email protected]> Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent 8e3be92 commit 09d72e7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

nav2_util/include/nav2_util/lifecycle_service_client.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class LifecycleServiceClient
3838
const std::string & lifecycle_node_name,
3939
rclcpp::Node::SharedPtr parent_node);
4040

41+
~LifecycleServiceClient()
42+
{
43+
change_state_.stop();
44+
get_state_.stop();
45+
}
46+
4147
/// Trigger a state change
4248
/**
4349
* Throws std::runtime_error on failure

nav2_util/include/nav2_util/service_client.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ class ServiceClient
204204
return service_name_;
205205
}
206206

207+
/**
208+
* @brief Stop any running spin operations on the internal executor
209+
*/
210+
void stop()
211+
{
212+
if (client_) {
213+
callback_group_executor_->cancel();
214+
}
215+
}
216+
207217
protected:
208218
std::string service_name_;
209219
NodeT node_;

0 commit comments

Comments
 (0)