Skip to content

Commit

Permalink
Fix SharedFuture from async_send_request never becomes valid (#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 committed Dec 2, 2022
1 parent a00ef22 commit 66b1944
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 66b1944

Please sign in to comment.