From 51c09b2329907ee3a90edbde4898affc6c739ddc Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Wed, 18 Dec 2024 17:22:33 +0100 Subject: [PATCH] Fix interest initialization --- include/zenoh-pico/session/interest.h | 1 + src/session/interest.c | 9 +++++++++ src/session/utils.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/include/zenoh-pico/session/interest.h b/include/zenoh-pico/session/interest.h index d8792ca77..7bebd99f7 100644 --- a/include/zenoh-pico/session/interest.h +++ b/include/zenoh-pico/session/interest.h @@ -29,6 +29,7 @@ _z_session_interest_rc_t *_z_register_interest(_z_session_t *zn, _z_session_inte void _z_unregister_interest(_z_session_t *zn, _z_session_interest_rc_t *intr); #endif // Z_FEATURE_INTEREST == 1 +void _z_interest_init(_z_session_t *zn); void _z_flush_interest(_z_session_t *zn); z_result_t _z_interest_process_declares(_z_session_t *zn, const _z_declaration_t *decl); z_result_t _z_interest_process_undeclares(_z_session_t *zn, const _z_declaration_t *decl); diff --git a/src/session/interest.c b/src/session/interest.c index 88a0626bd..1ef8f033b 100644 --- a/src/session/interest.c +++ b/src/session/interest.c @@ -394,6 +394,13 @@ void _z_unregister_interest(_z_session_t *zn, _z_session_interest_rc_t *intr) { _z_session_mutex_unlock(zn); } +void _z_interest_init(_z_session_t *zn) { + _z_session_mutex_lock(zn); + zn->_local_interests = NULL; + zn->_remote_declares = NULL; + _z_session_mutex_unlock(zn); +} + void _z_flush_interest(_z_session_t *zn) { _z_session_mutex_lock(zn); _z_session_interest_rc_list_free(&zn->_local_interests); @@ -457,6 +464,8 @@ z_result_t _z_interest_process_interest(_z_session_t *zn, _z_keyexpr_t key, uint } #else +void _z_interest_init(_z_session_t *zn) { _ZP_UNUSED(zn); } + void _z_flush_interest(_z_session_t *zn) { _ZP_UNUSED(zn); } z_result_t _z_interest_process_declares(_z_session_t *zn, const _z_declaration_t *decl) { diff --git a/src/session/utils.c b/src/session/utils.c index 90ec97912..89d92cdd4 100644 --- a/src/session/utils.c +++ b/src/session/utils.c @@ -88,6 +88,8 @@ z_result_t _z_session_init(_z_session_rc_t *zsrc, _z_id_t *zid) { _z_liveliness_init(zn); #endif + _z_interest_init(zn); + zn->_local_zid = *zid; // Note session in transport switch (zn->_tp._type) {