Skip to content

Commit 378223d

Browse files
Mauro Passerinoapojomovsky
authored andcommitted
clear intra-process manager on client/server destructors (#94)
1 parent 10f6adc commit 378223d

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

rclcpp/include/rclcpp/experimental/intra_process_manager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class IntraProcessManager
369369
auto warning_msg =
370370
"Intra-process service gone out of scope. "
371371
"Do inter-process requests.\n"
372-
"Client topic name: " + std::string(cli->get_service_name());
372+
"Client service name: " + std::string(cli->get_service_name());
373373
RCLCPP_WARN(rclcpp::get_logger("rclcpp"), warning_msg.c_str());
374374
return;
375375
}

rclcpp_action/include/rclcpp_action/client.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,19 @@ class Client : public ClientBase
668668
}
669669
it = goal_handles_.erase(it);
670670
}
671+
672+
if (!use_intra_process_) {
673+
return;
674+
}
675+
auto ipm = weak_ipm_.lock();
676+
if (!ipm) {
677+
// TODO(ivanpauno): should this raise an error?
678+
RCLCPP_WARN(
679+
rclcpp::get_logger("rclcpp"),
680+
"Intra process manager died before than an action client.");
681+
return;
682+
}
683+
ipm->remove_action_client(ipc_action_client_id_);
671684
}
672685

673686
private:

rclcpp_action/include/rclcpp_action/server.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,21 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
478478
}
479479
}
480480

481-
virtual ~Server() = default;
481+
virtual ~Server()
482+
{
483+
if (!use_intra_process_) {
484+
return;
485+
}
486+
auto ipm = weak_ipm_.lock();
487+
if (!ipm) {
488+
// TODO(ivanpauno): should this raise an error?
489+
RCLCPP_WARN(
490+
rclcpp::get_logger("rclcpp"),
491+
"Intra process manager died before than an action server.");
492+
return;
493+
}
494+
ipm->remove_action_server(ipc_action_server_id_);
495+
}
482496

483497
protected:
484498
// Intra-process version of execute_goal_request_received_

0 commit comments

Comments
 (0)