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
Signed-off-by: Lei Liu <Lei.Liu.AP@sony.com>
  • Loading branch information
llapx authored and Alberto Soragna committed Apr 29, 2023
1 parent 0a1234b commit 72d44df
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 @@ -866,16 +866,14 @@ class Client : public ClientBase

// Send inter-process request
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.get(), &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 72d44df

Please sign in to comment.