Skip to content

Commit 990927f

Browse files
committed
nav2_util: break LifecycleServiceClient ctor wait loop on shutdown
LifecycleServiceClient's constructor blocks on wait_for_service() in a loop. If the rcl context is invalidated mid-construction (e.g. the process receives SIGINT before the dependent service comes up), both wait_for_service() and Rate::sleep() return immediately, which spins the loop tight and prevents the process from exiting. Surfaced by test_costmap_subscriber_exec: after the gtest binary now exits in ~50ms (post-PR-#5834 fixes), the launch wrapper SIGINTs a lifecycle_manager whose constructor was still in this loop, and the ctest timeout fires while the manager refuses to die. Add an rclcpp::ok() check to the loop condition so context shutdown breaks construction cleanly. Signed-off-by: lotusymt <mengtiy5@uci.edu>
1 parent 7e73798 commit 990927f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

nav2_util/include/nav2_util/lifecycle_service_client.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ class LifecycleServiceClient
4444
get_state_(lifecycle_node_name + "/get_state", parent_node,
4545
true /*creates and spins an internal executor*/)
4646
{
47-
// Block until server is up
47+
// Block until server is up, but bail out if the context is shutting down
48+
// so we don't spin forever after SIGINT during construction.
4849
rclcpp::Rate r(20);
49-
while (!get_state_.wait_for_service(2s)) {
50+
while (rclcpp::ok() && !get_state_.wait_for_service(2s)) {
5051
RCLCPP_INFO(
5152
parent_node->get_logger(),
5253
"Waiting for service %s...", get_state_.getServiceName().c_str());

0 commit comments

Comments
 (0)