Skip to content

Commit

Permalink
fix: clear interest data on session close
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Mar 21, 2024
1 parent e7e0b77 commit bb9cf3c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/interest.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
_z_session_interest_rc_t *_z_get_interest_by_id(_z_session_t *zn, const _z_zint_t id);
_z_session_interest_rc_t *_z_register_interest(_z_session_t *zn, _z_session_interest_t *intr);
void _z_unregister_interest(_z_session_t *zn, _z_session_interest_rc_t *intr);
void _z_flush_interest(_z_session_t *zn);
#endif // Z_FEATURE_INTEREST == 1

void _z_flush_interest(_z_session_t *zn);
int8_t _z_interest_process_declares(_z_session_t *zn, const _z_declaration_t *decl);
int8_t _z_interest_process_undeclares(_z_session_t *zn, const _z_declaration_t *decl);
int8_t _z_interest_process_final_interest(_z_session_t *zn, uint32_t id);
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh-pico/session/session.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ typedef struct {
uint8_t _type;
} _z_declare_data_t;

void _z_declare_data_clear(_z_declare_data_t * data);
void _z_declare_data_clear(_z_declare_data_t *data);
_Z_ELEM_DEFINE(_z_declare_data, _z_declare_data_t, _z_noop_size, _z_declare_data_clear, _z_noop_copy)
_Z_LIST_DEFINE(_z_declare_data, _z_declare_data_t)

Expand Down
3 changes: 3 additions & 0 deletions src/session/interest.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ void _z_unregister_interest(_z_session_t *zn, _z_session_interest_rc_t *intr) {
void _z_flush_interest(_z_session_t *zn) {
_zp_session_lock_mutex(zn);
_z_session_interest_rc_list_free(&zn->_local_interests);
_z_declare_data_list_free(&zn->_remote_declares);
_zp_session_unlock_mutex(zn);
}

Expand Down Expand Up @@ -407,6 +408,8 @@ int8_t _z_interest_process_declare_interest(_z_session_t *zn, _z_keyexpr_t key,
}

#else
void _z_flush_interest(_z_session_t *zn) { _ZP_UNUSED(zn); }

Check warning

Code scanning / Cppcheck (reported by Codacy)

misra violation 804 with no text in the supplied rule-texts-file Warning

misra violation 804 with no text in the supplied rule-texts-file

int8_t _z_interest_process_declares(_z_session_t *zn, const _z_declaration_t *decl) {
_ZP_UNUSED(zn);
_ZP_UNUSED(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 @@ -18,6 +18,7 @@

#include "zenoh-pico/config.h"
#include "zenoh-pico/protocol/core.h"
#include "zenoh-pico/session/interest.h"
#include "zenoh-pico/session/query.h"
#include "zenoh-pico/session/queryable.h"
#include "zenoh-pico/session/resource.h"
Expand Down Expand Up @@ -115,6 +116,7 @@ void _z_session_clear(_z_session_t *zn) {
#if Z_FEATURE_QUERY == 1
_z_flush_pending_queries(zn);
#endif
_z_flush_interest(zn);

#if Z_FEATURE_MULTI_THREAD == 1
zp_mutex_free(&zn->_mutex_inner);
Expand Down

0 comments on commit bb9cf3c

Please sign in to comment.