Skip to content

Commit

Permalink
Fix SharedFuture from async_send_request never becomes valid (ros2#2044
Browse files Browse the repository at this point in the history
…) (ros2#2076) (#6)

(cherry picked from commit 66b1944)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Lei Liu <64953129+llapx@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 30, 2023
1 parent 3e2e6a9 commit 0189b7c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rclcpp/include/rclcpp/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,16 +792,14 @@ class Client : public ClientBase
async_send_request_impl(const Request & request, CallbackInfoVariant value)
{
int64_t sequence_number;
std::lock_guard<std::mutex> lock(pending_requests_mutex_);
rcl_ret_t ret = rcl_send_request(get_client_handle().get(), &request, &sequence_number);
if (RCL_RET_OK != ret) {
rclcpp::exceptions::throw_from_rcl_error(ret, "failed to send request");
}
{
std::lock_guard<std::mutex> lock(pending_requests_mutex_);
pending_requests_.try_emplace(
sequence_number,
std::make_pair(std::chrono::system_clock::now(), std::move(value)));
}
pending_requests_.try_emplace(
sequence_number,
std::make_pair(std::chrono::system_clock::now(), std::move(value)));
return sequence_number;
}

Expand Down

0 comments on commit 0189b7c

Please sign in to comment.