Skip to content

Commit

Permalink
Revert "LifecycleNode shutdown on dtor only with valid context. (#2545)"
Browse files Browse the repository at this point in the history
This reverts commit d8d83a0.

Signed-off-by: Tomoya Fujita <[email protected]>
  • Loading branch information
fujitatomoya committed Jun 10, 2024
1 parent 7c09688 commit 2c25337
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions rclcpp_lifecycle/src/lifecycle_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,15 @@ LifecycleNode::~LifecycleNode()
auto current_state = LifecycleNode::get_current_state().id();
// shutdown if necessary to avoid leaving the device in any other primary state
if (current_state < lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED) {
if (node_base_->get_context()->is_valid()) {
auto ret = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::ERROR;
auto finalized = LifecycleNode::shutdown(ret);
if (finalized.id() != lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED ||
ret != rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS)
{
RCLCPP_WARN(
rclcpp::get_logger("rclcpp_lifecycle"),
"Shutdown error in destruction of LifecycleNode: final state(%s)",
finalized.label().c_str());
}
} else {
// TODO(fujitatomoya): consider when context is gracefully shutdown before.
RCLCPP_DEBUG(
auto ret = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::ERROR;
auto finalized = LifecycleNode::shutdown(ret);
if (finalized.id() != lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED ||
ret != rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn::SUCCESS)
{
RCLCPP_WARN(
rclcpp::get_logger("rclcpp_lifecycle"),
"Context invalid error in destruction of LifecycleNode: Node still in transition state(%u)",
current_state);
"Shutdown error in destruction of LifecycleNode: final state(%s)",
finalized.label().c_str());
}
} else if (current_state > lifecycle_msgs::msg::State::PRIMARY_STATE_FINALIZED) {
RCLCPP_WARN(
Expand All @@ -182,7 +174,6 @@ LifecycleNode::~LifecycleNode()

// release sub-interfaces in an order that allows them to consult with node_base during tear-down
node_waitables_.reset();
node_type_descriptions_.reset();
node_time_source_.reset();
node_parameters_.reset();
node_clock_.reset();
Expand All @@ -191,7 +182,6 @@ LifecycleNode::~LifecycleNode()
node_timers_.reset();
node_logging_.reset();
node_graph_.reset();
node_base_.reset();
}

const char *
Expand Down

0 comments on commit 2c25337

Please sign in to comment.