Skip to content

Commit

Permalink
Make sure to give ownership of the closure to Zenoh.
Browse files Browse the repository at this point in the history
That is, we should be using z_move() to hand responsibility
of the closure to Zenoh.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Jul 1, 2024
1 parent 0eb4560 commit cc263bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion rmw_zenoh_cpp/src/detail/rmw_data_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ class rmw_client_data_t final
std::shared_ptr<liveliness::Entity> entity;

z_owned_keyexpr_t keyexpr;
z_owned_closure_reply_t zn_closure_reply;

// Store the actual QoS profile used to configure this client.
// The QoS is reused for sending requests and getting responses.
Expand Down
9 changes: 5 additions & 4 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,6 @@ rmw_destroy_client(rmw_node_t * node, rmw_client_t * client)
return RMW_RET_INVALID_ARGUMENT);

// CLEANUP ===================================================================
z_drop(z_move(client_data->zn_closure_reply));
z_drop(z_move(client_data->keyexpr));
zc_liveliness_undeclare_token(z_move(client_data->token));

Expand Down Expand Up @@ -2464,11 +2463,13 @@ rmw_send_request(
// and any number.
opts.consolidation = z_query_consolidation_latest();
opts.value.payload = z_bytes_t{data_length, reinterpret_cast<const uint8_t *>(request_bytes)};
client_data->zn_closure_reply =
z_owned_closure_reply_t zn_closure_reply =
z_closure(rmw_zenoh_cpp::client_data_handler, nullptr, client_data);
z_get(
z_loan(context_impl->session), z_loan(
client_data->keyexpr), "", &client_data->zn_closure_reply, &opts);
z_loan(context_impl->session),
z_loan(client_data->keyexpr), "",
z_move(zn_closure_reply),
&opts);

return RMW_RET_OK;
}
Expand Down

0 comments on commit cc263bb

Please sign in to comment.