Skip to content

Commit 7a51f00

Browse files
mauropasseMauro PasserinojmachowinskiJanosch Machowinskiwjwwood
authored
Iron: Action IPC Fixes (#151)
* Fixes for intra-process actions (#144) * Fixes for intra-process Actions * Fixes for Clang builds * Fix deadlock * Server to store results until client requests them * Fix feedback/result data race See ros2#2451 * Add missing mutex * Check return value of intra_process_action_send --------- Co-authored-by: Mauro Passerino <[email protected]> * Fix IPC Actions data race (#147) * Check if goal was sent through IPC before send responses * Add intra_process_action_server_is_available API to intra-process Client --------- Co-authored-by: Mauro Passerino <[email protected]> * Fix data race in Actions: Part 2 (#148) * Fix data race in Actions: Part 2 * Fix warning - copy elision --------- Co-authored-by: Mauro Passerino <[email protected]> * fix: Fixed race condition in action server between is_ready and take"… (ros2#2531) * fix: Fixed race condition in action server between is_ready and take" (ros2#2495) Some background information: is_ready, take_data and execute data may be called from different threads in any order. The code in the old state expected them to be called in series, without interruption. This lead to multiple race conditions, as the state of the pimpl objects was altered by the three functions in a non thread safe way. Co-authored-by: William Woodall <[email protected]> Signed-off-by: Janosch Machowinski <[email protected]> * fix: added workaround for call to double calls to take_data This adds a workaround for a known bug in the executor in iron. Signed-off-by: Janosch Machowinski <[email protected]> --------- Signed-off-by: Janosch Machowinski <[email protected]> Co-authored-by: Janosch Machowinski <[email protected]> Co-authored-by: William Woodall <[email protected]> --------- Signed-off-by: Janosch Machowinski <[email protected]> Co-authored-by: Mauro Passerino <[email protected]> Co-authored-by: jmachowinski <[email protected]> Co-authored-by: Janosch Machowinski <[email protected]> Co-authored-by: William Woodall <[email protected]>
1 parent aef928d commit 7a51f00

File tree

5 files changed

+591
-251
lines changed

5 files changed

+591
-251
lines changed

rclcpp/include/rclcpp/experimental/intra_process_manager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ class IntraProcessManager
10611061
auto ptr = MessageAllocTraits::allocate(allocator, 1);
10621062
MessageAllocTraits::construct(allocator, ptr, *message);
10631063

1064-
subscription->provide_intra_process_data(std::move(MessageUniquePtr(ptr, deleter)));
1064+
subscription->provide_intra_process_data(MessageUniquePtr(ptr, deleter));
10651065
}
10661066

10671067
continue;
@@ -1104,7 +1104,7 @@ class IntraProcessManager
11041104
MessageAllocTraits::construct(allocator, ptr, *message);
11051105

11061106
ros_message_subscription->provide_intra_process_message(
1107-
std::move(MessageUniquePtr(ptr, deleter)));
1107+
MessageUniquePtr(ptr, deleter));
11081108
}
11091109
}
11101110
}

rclcpp_action/include/rclcpp_action/client.hpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@ class ClientBase : public rclcpp::Waitable
9797
);
9898
}
9999

100+
/// Return true if there is an intra-process action server that is ready to take goal requests.
101+
bool
102+
intra_process_action_server_is_available()
103+
{
104+
if (auto ipm = weak_ipm_.lock()) {
105+
return ipm->action_server_is_available(ipc_action_client_id_);
106+
}
107+
return false;
108+
}
109+
100110
// -------------
101111
// Waitables API
102112

@@ -835,12 +845,18 @@ class Client : public ClientBase
835845
// the server might be available in another process or was configured to not use IPC.
836846
if (intra_process_server_available) {
837847
size_t hashed_guuid = std::hash<GoalUUID>()(goal_handle->get_goal_id());
838-
ipc_action_client_->store_result_response_callback(
839-
hashed_guuid, result_response_callback);
840848

841-
intra_process_send_done = ipm->template intra_process_action_send_result_request<ActionT>(
842-
ipc_action_client_id_,
843-
std::move(goal_result_request));
849+
// Determine if goal was sent through inter or intra process by checking the goal ID
850+
bool goal_sent_by_ipc = ipm->get_action_client_id_from_goal_uuid(hashed_guuid);
851+
852+
if (goal_sent_by_ipc) {
853+
ipc_action_client_->store_result_response_callback(
854+
hashed_guuid, result_response_callback);
855+
856+
intra_process_send_done = ipm->template intra_process_action_send_result_request<ActionT>(
857+
ipc_action_client_id_,
858+
std::move(goal_result_request));
859+
}
844860
}
845861
}
846862

rclcpp_action/include/rclcpp_action/server.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ class Server : public ServerBase, public std::enable_shared_from_this<Server<Act
675675
rclcpp::get_logger("rclcpp_action"),
676676
"Action server can't send result response, missing IPC Action client: %s. "
677677
"Will do inter-process publish",
678-
this->action_name_.c_str());
678+
this->action_name_);
679+
679680
return true;
680681
}
681682

0 commit comments

Comments
 (0)