Skip to content

Commit

Permalink
Fix interest initialization (#839)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc authored Dec 18, 2024
1 parent 24b66a2 commit 86f4c7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/zenoh-pico/session/interest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/session/interest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/session/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 86f4c7c

Please sign in to comment.