Skip to content

Commit 3e7d6a4

Browse files
Mauro Passerinoskyegalaxy
authored andcommitted
clear intra-process manager on client/server destructors (#94)
(cherry picked from commit 378223d)
1 parent 5539d43 commit 3e7d6a4

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

rclcpp/include/rclcpp/experimental/intra_process_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class IntraProcessManager
410410
auto warning_msg =
411411
"Intra-process service gone out of scope. "
412412
"Do inter-process requests.\n"
413-
"Client topic name: " + std::string(cli->get_service_name());
413+
"Client service name: " + std::string(cli->get_service_name());
414414
RCLCPP_WARN(rclcpp::get_logger("rclcpp"), warning_msg.c_str());
415415
return;
416416
}

rclcpp_action/include/rclcpp_action/client.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,19 @@ class Client : public ClientBase
734734
}
735735
it = goal_handles_.erase(it);
736736
}
737+
738+
if (!use_intra_process_) {
739+
return;
740+
}
741+
auto ipm = weak_ipm_.lock();
742+
if (!ipm) {
743+
// TODO(ivanpauno): should this raise an error?
744+
RCLCPP_WARN(
745+
rclcpp::get_logger("rclcpp"),
746+
"Intra process manager died before than an action client.");
747+
return;
748+
}
749+
ipm->remove_action_client(ipc_action_client_id_);
737750
}
738751

739752
private:

rclcpp_action/include/rclcpp_action/server.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,21 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
455455
}
456456
}
457457

458-
virtual ~Server() = default;
458+
virtual ~Server()
459+
{
460+
if (!use_intra_process_) {
461+
return;
462+
}
463+
auto ipm = weak_ipm_.lock();
464+
if (!ipm) {
465+
// TODO(ivanpauno): should this raise an error?
466+
RCLCPP_WARN(
467+
rclcpp::get_logger("rclcpp"),
468+
"Intra process manager died before than an action server.");
469+
return;
470+
}
471+
ipm->remove_action_server(ipc_action_server_id_);
472+
}
459473

460474
protected:
461475
// Intra-process version of execute_goal_request_received_

0 commit comments

Comments
 (0)