Skip to content

Commit

Permalink
Remove service entries if gone out of scope
Browse files Browse the repository at this point in the history
Signed-off-by: Mauro Passerino <mpasserino@irobot.com>
  • Loading branch information
Mauro Passerino committed Oct 3, 2022
1 parent 0a98fda commit d45b7ea
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions rclcpp/include/rclcpp/experimental/intra_process_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,23 @@ class IntraProcessManager

auto service_it = services_.find(service_id);
if (service_it == services_.end()) {
throw std::runtime_error(
"There are no services to receive the intra-process request. "
"Do Inter process.");
auto cli = get_client_intra_process(intra_process_client_id);
auto warning_msg =
"Intra-process service gone out of scope. "
"Do inter-process requests.\n"
"Client topic name: " + std::string(cli->get_service_name());
RCLCPP_WARN(rclcpp::get_logger("rclcpp"), warning_msg.c_str());

// Remove all entries of the out-of-scope service
// from the client/service pairs.
for (auto it = clients_to_services_.cbegin(); it != clients_to_services_.cend(); ) {
if (it->second == service_id) {
it = clients_to_services_.erase(it);
} else {
it++;
}
}
return;
}
auto service_intra_process_base = service_it->second.lock();
if (service_intra_process_base) {
Expand Down

0 comments on commit d45b7ea

Please sign in to comment.