Skip to content

Commit

Permalink
Merge commit 'be31a20eda3ee9325dff022df2d1480a243d274c'
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowhatter committed Aug 23, 2024
2 parents 916ee65 + be31a20 commit aff62d3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 126 deletions.
16 changes: 6 additions & 10 deletions rmw_zenoh_cpp/src/detail/rmw_data_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,12 @@ void client_data_handler(const z_loaned_reply_t *reply, void *data) {
return;
}

if (!z_reply_is_ok(reply)) {
if (z_reply_is_ok(reply))
{
z_owned_reply_t owned_reply;
z_reply_clone(&owned_reply, reply);
client_data->add_new_reply(std::make_unique<ZenohReply>(&owned_reply));
} else {
z_view_string_t keystr;
z_keyexpr_as_view_string(z_loan(client_data->keyexpr), &keystr);
const z_loaned_reply_err_t *err = z_reply_err(reply);
Expand All @@ -545,15 +550,6 @@ void client_data_handler(const z_loaned_reply_t *reply, void *data) {
z_drop(z_move(err_str));
return;
}
z_owned_reply_t owned_reply;
z_reply_clone(&owned_reply, reply);

if (!z_reply_check(&owned_reply)) {
RMW_ZENOH_LOG_ERROR_NAMED("rmw_zenoh_cpp", "z_reply_check returned False");
return;
}

client_data->add_new_reply(std::make_unique<ZenohReply>(&owned_reply));
}

void client_data_drop(void *data) {
Expand Down
15 changes: 2 additions & 13 deletions rmw_zenoh_cpp/src/rmw_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,25 +351,14 @@ rmw_ret_t rmw_init(const rmw_init_options_t *options, rmw_context_t *context) {

z_view_keyexpr_from_str(&keyexpr, liveliness_str.c_str());

zc_liveliness_declare_subscriber(
if(zc_liveliness_declare_subscriber(
&context->impl->graph_subscriber,
z_loan(context->impl->session), z_loan(keyexpr),
z_move(callback), &sub_options);

const z_loaned_keyexpr_t *sub_ke = z_subscriber_keyexpr(z_loan(context->impl->graph_subscriber));
z_view_string_t sub_keyexpr;
z_keyexpr_as_view_string(sub_ke, &sub_keyexpr);


auto undeclare_z_sub = rcpputils::make_scope_exit([context]() {
z_undeclare_subscriber(z_move(context->impl->graph_subscriber));
});
if (!z_check(context->impl->graph_subscriber)) {
z_move(callback), &sub_options) != Z_OK) {
RMW_SET_ERROR_MSG("unable to create zenoh subscription");
return RMW_RET_ERROR;
}

undeclare_z_sub.cancel();
close_session.cancel();
destruct_guard_condition_data.cancel();
impl_destructor.cancel();
Expand Down
Loading

0 comments on commit aff62d3

Please sign in to comment.