Skip to content

Commit

Permalink
Optimization + warning fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 4, 2024
1 parent ee58cab commit b648506
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/session/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ z_result_t _z_liveliness_pending_query_reply(_z_session_t *zn, uint32_t interest
ret = _Z_ERR_ENTITY_UNKNOWN;
}

_Z_DEBUG("Liveliness pending query reply %i resolve result %i", interest_id, ret);
_Z_DEBUG("Liveliness pending query reply %i resolve result %i", (int)interest_id, ret);

if (ret == _Z_RES_OK) {
_Z_DEBUG("Resolving %d - %.*s on mapping 0x%x", keyexpr._id, (int)_z_string_len(&keyexpr._suffix),
Expand Down Expand Up @@ -131,7 +131,7 @@ z_result_t _z_liveliness_pending_query_drop(_z_session_t *zn, uint32_t interest_
ret = _Z_ERR_ENTITY_UNKNOWN;
}

_Z_DEBUG("Liveliness pending query drop %i resolve result %i", interest_id, ret);
_Z_DEBUG("Liveliness pending query drop %i resolve result %i", (int)interest_id, ret);

if (ret == _Z_RES_OK) {
_z_liveliness_pending_query_intmap_remove(&zn->_liveliness_pending_queries, interest_id);
Expand Down Expand Up @@ -176,23 +176,22 @@ z_result_t _z_liveliness_subscription_undeclare(_z_session_t *zn, uint32_t id, c
z_result_t ret = _Z_RES_OK;

_zp_session_lock_mutex(zn);

const _z_keyexpr_t *pkeyexpr = _z_keyexpr_intmap_get(&zn->_remote_tokens, id);
if (pkeyexpr == NULL) {
ret = _Z_ERR_ENTITY_UNKNOWN;
}
// TODO(sashacmc): review order to avoid keyexpt copy
_z_keyexpr_t keyexpr;
_zp_session_unlock_mutex(zn);

if (ret == _Z_RES_OK) {
_z_keyexpr_copy(&keyexpr, pkeyexpr);
_z_keyexpr_intmap_remove(&zn->_remote_tokens, id);
ret = _z_trigger_liveliness_subscriptions_undeclare(zn, *pkeyexpr, timestamp);
}

_zp_session_unlock_mutex(zn);

if (ret == _Z_RES_OK) {
ret = _z_trigger_liveliness_subscriptions_undeclare(zn, keyexpr, timestamp);
_zp_session_lock_mutex(zn);
_z_keyexpr_intmap_remove(&zn->_remote_tokens, id);
_zp_session_unlock_mutex(zn);
}

return ret;
}

Expand Down

0 comments on commit b648506

Please sign in to comment.