Skip to content

Commit

Permalink
Fix token type
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Nov 4, 2024
1 parent 52495d2 commit 16b3785
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/zenoh-pico/api/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "zenoh-pico/protocol/core.h"

typedef struct {
_z_zint_t _id;
uint32_t _id;
_z_keyexpr_t _key;
_z_session_weak_t _zn;
} _z_liveliness_token_t;
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/net/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ typedef struct _z_session_t {
#endif

#if Z_FEATURE_LIVELINESS == 1
_z_zint_t _liveliness_query_id;
uint32_t _liveliness_query_id;
_z_keyexpr_intmap_t _local_tokens;
_z_keyexpr_intmap_t _remote_tokens;
_z_liveliness_pending_query_intmap_t _liveliness_pending_queries;
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh-pico/session/liveliness.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
#define ZENOH_PICO_SESSION_LIVELINESS_H

#if Z_FEATURE_QUERYABLE == 1
_z_zint_t _z_liveliness_get_query_id(_z_session_t *zn);
uint32_t _z_liveliness_get_query_id(_z_session_t *zn);

z_result_t _z_liveliness_register_pending_query(_z_session_t *zn, _z_zint_t id, _z_liveliness_pending_query_t *pen_qry);
void _z_liveliness_unregister_pending_query(_z_session_t *zn, _z_zint_t id);
z_result_t _z_liveliness_register_pending_query(_z_session_t *zn, uint32_t id, _z_liveliness_pending_query_t *pen_qry);
void _z_liveliness_unregister_pending_query(_z_session_t *zn, uint32_t id);

z_result_t _z_liveliness_process_token_declare(_z_session_t *zn, const _z_n_msg_declare_t *decl);
z_result_t _z_liveliness_process_token_undeclare(_z_session_t *zn, const _z_n_msg_declare_t *decl);
z_result_t _z_liveliness_process_declare_final(_z_session_t *zn, const _z_n_msg_declare_t *decl);

z_result_t _z_liveliness_register_token(_z_session_t *zn, _z_zint_t id, const _z_keyexpr_t keyexpr);
void _z_liveliness_unregister_token(_z_session_t *zn, _z_zint_t id);
z_result_t _z_liveliness_register_token(_z_session_t *zn, uint32_t id, const _z_keyexpr_t keyexpr);
void _z_liveliness_unregister_token(_z_session_t *zn, uint32_t id);

void _z_liveliness_init(_z_session_t *zn);
void _z_liveliness_clear(_z_session_t *zn);
Expand Down
2 changes: 1 addition & 1 deletion src/net/primitives.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ z_result_t _z_liveliness_query(_z_session_t *zn, _z_keyexpr_t keyexpr, _z_closur
_z_liveliness_pending_query_t *pq =
(_z_liveliness_pending_query_t *)z_malloc(sizeof(_z_liveliness_pending_query_t));
if (pq != NULL) {
_z_zint_t id = _z_liveliness_get_query_id(zn);
uint32_t id = _z_liveliness_get_query_id(zn);
pq->_key = _z_get_expanded_key_from_key(zn, &keyexpr);
pq->_callback = callback;
pq->_dropper = dropper;
Expand Down
21 changes: 10 additions & 11 deletions src/session/liveliness.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ _z_liveliness_pending_query_t *_z_liveliness_pending_query_clone(const _z_liveli
return dst;
}

_z_zint_t _z_liveliness_get_query_id(_z_session_t *zn) { return zn->_liveliness_query_id++; }
uint32_t _z_liveliness_get_query_id(_z_session_t *zn) { return zn->_liveliness_query_id++; }

z_result_t _z_liveliness_register_pending_query(_z_session_t *zn, _z_zint_t id,
_z_liveliness_pending_query_t *pen_qry) {
z_result_t _z_liveliness_register_pending_query(_z_session_t *zn, uint32_t id, _z_liveliness_pending_query_t *pen_qry) {
z_result_t ret = _Z_RES_OK;

_Z_DEBUG(">>> Allocating liveliness query for (%ju:%.*s)", (uintmax_t)pen_qry->_key._id,
Expand All @@ -65,7 +64,7 @@ z_result_t _z_liveliness_register_pending_query(_z_session_t *zn, _z_zint_t id,
const _z_liveliness_pending_query_t *pq =
_z_liveliness_pending_query_intmap_get(&zn->_liveliness_pending_queries, id);
if (pq != NULL) {
_Z_ERROR("Duplicate liveliness query id %lu", id);
_Z_ERROR("Duplicate liveliness query id %u", id);
ret = _Z_ERR_ENTITY_DECLARATION_FAILED;
} else {
_z_liveliness_pending_query_intmap_insert(&zn->_liveliness_pending_queries, id,
Expand Down Expand Up @@ -143,15 +142,15 @@ z_result_t _z_liveliness_pending_query_drop(_z_session_t *zn, uint32_t interest_
return ret;
}

void _z_liveliness_unregister_pending_query(_z_session_t *zn, _z_zint_t id) {
void _z_liveliness_unregister_pending_query(_z_session_t *zn, uint32_t id) {
_zp_session_lock_mutex(zn);

_z_liveliness_pending_query_intmap_remove(&zn->_liveliness_pending_queries, id);

_zp_session_unlock_mutex(zn);
}

z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, _z_zint_t id, const _z_keyexpr_t keyexpr,
z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, uint32_t id, const _z_keyexpr_t keyexpr,
const _z_timestamp_t *timestamp) {
z_result_t ret = _Z_RES_OK;
// TODO(sashacmc): What about history? Currently tokens decalred before subscription started, not processed
Expand All @@ -161,7 +160,7 @@ z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, _z_zint_t id, co

const _z_keyexpr_t *pkeyexpr = _z_keyexpr_intmap_get(&zn->_remote_tokens, id);
if (pkeyexpr != NULL) {
_Z_ERROR("Duplicate token id %lu", id);
_Z_ERROR("Duplicate token id %u", id);
ret = _Z_ERR_ENTITY_DECLARATION_FAILED;
} else {
_z_keyexpr_intmap_insert(&zn->_remote_tokens, id, _z_keyexpr_clone(&keyexpr));
Expand All @@ -173,7 +172,7 @@ z_result_t _z_liveliness_subscription_declare(_z_session_t *zn, _z_zint_t id, co
return ret;
}

z_result_t _z_liveliness_subscription_undeclare(_z_session_t *zn, _z_zint_t id, const _z_timestamp_t *timestamp) {
z_result_t _z_liveliness_subscription_undeclare(_z_session_t *zn, uint32_t id, const _z_timestamp_t *timestamp) {
z_result_t ret = _Z_RES_OK;

_zp_session_lock_mutex(zn);
Expand All @@ -197,14 +196,14 @@ z_result_t _z_liveliness_subscription_undeclare(_z_session_t *zn, _z_zint_t id,
return ret;
}

z_result_t _z_liveliness_register_token(_z_session_t *zn, _z_zint_t id, const _z_keyexpr_t keyexpr) {
z_result_t _z_liveliness_register_token(_z_session_t *zn, uint32_t id, const _z_keyexpr_t keyexpr) {
z_result_t ret = _Z_RES_OK;

_zp_session_lock_mutex(zn);

const _z_keyexpr_t *pkeyexpr = _z_keyexpr_intmap_get(&zn->_local_tokens, id);
if (pkeyexpr != NULL) {
_Z_ERROR("Duplicate token id %lu", id);
_Z_ERROR("Duplicate token id %u", id);
ret = _Z_ERR_ENTITY_DECLARATION_FAILED;
} else {
_z_keyexpr_intmap_insert(&zn->_local_tokens, id, _z_keyexpr_clone(&keyexpr));
Expand All @@ -215,7 +214,7 @@ z_result_t _z_liveliness_register_token(_z_session_t *zn, _z_zint_t id, const _z
return ret;
}

void _z_liveliness_unregister_token(_z_session_t *zn, _z_zint_t id) {
void _z_liveliness_unregister_token(_z_session_t *zn, uint32_t id) {
_zp_session_lock_mutex(zn);

_z_keyexpr_intmap_remove(&zn->_local_tokens, id);
Expand Down

0 comments on commit 16b3785

Please sign in to comment.