Skip to content

Commit

Permalink
Fix multiply declaration restore
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Dec 13, 2024
1 parent abff572 commit ef0ebb8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
37 changes: 19 additions & 18 deletions include/zenoh-pico/collections/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,25 @@ _z_list_t *_z_list_drop_filter(_z_list_t *xs, z_element_free_f f_f, z_element_eq
_z_list_t *_z_list_clone(const _z_list_t *xs, z_element_clone_f d_f);
void _z_list_free(_z_list_t **xs, z_element_free_f f_f);

#define _Z_LIST_DEFINE(name, type) \
typedef _z_list_t name##_list_t; \
static inline name##_list_t *name##_list_new(void) { return NULL; } \
static inline size_t name##_list_len(const name##_list_t *l) { return _z_list_len(l); } \
static inline bool name##_list_is_empty(const name##_list_t *l) { return _z_list_is_empty(l); } \
static inline type *name##_list_head(const name##_list_t *l) { return (type *)_z_list_head(l); } \
static inline name##_list_t *name##_list_tail(const name##_list_t *l) { return _z_list_tail(l); } \
static inline name##_list_t *name##_list_push(name##_list_t *l, type *e) { return _z_list_push(l, e); } \
static inline name##_list_t *name##_list_pop(name##_list_t *l, type **x) { \
return _z_list_pop(l, name##_elem_free, (void **)x); \
} \
static inline name##_list_t *name##_list_find(const name##_list_t *l, name##_eq_f c_f, type *e) { \
return _z_list_find(l, (z_element_eq_f)c_f, e); \
} \
static inline name##_list_t *name##_list_drop_filter(name##_list_t *l, name##_eq_f c_f, type *e) { \
return _z_list_drop_filter(l, name##_elem_free, (z_element_eq_f)c_f, e); \
} \
static inline name##_list_t *name##_list_clone(name##_list_t *l) { return _z_list_clone(l, name##_elem_clone); } \
#define _Z_LIST_DEFINE(name, type) \
typedef _z_list_t name##_list_t; \
static inline name##_list_t *name##_list_new(void) { return NULL; } \
static inline size_t name##_list_len(const name##_list_t *l) { return _z_list_len(l); } \
static inline bool name##_list_is_empty(const name##_list_t *l) { return _z_list_is_empty(l); } \
static inline type *name##_list_head(const name##_list_t *l) { return (type *)_z_list_head(l); } \
static inline name##_list_t *name##_list_tail(const name##_list_t *l) { return _z_list_tail(l); } \
static inline name##_list_t *name##_list_push(name##_list_t *l, type *e) { return _z_list_push(l, e); } \
static inline name##_list_t *name##_list_push_back(name##_list_t *l, type *e) { return _z_list_push_back(l, e); } \
static inline name##_list_t *name##_list_pop(name##_list_t *l, type **x) { \
return _z_list_pop(l, name##_elem_free, (void **)x); \
} \
static inline name##_list_t *name##_list_find(const name##_list_t *l, name##_eq_f c_f, type *e) { \
return _z_list_find(l, (z_element_eq_f)c_f, e); \
} \
static inline name##_list_t *name##_list_drop_filter(name##_list_t *l, name##_eq_f c_f, type *e) { \
return _z_list_drop_filter(l, name##_elem_free, (z_element_eq_f)c_f, e); \
} \
static inline name##_list_t *name##_list_clone(name##_list_t *l) { return _z_list_clone(l, name##_elem_clone); } \
static inline void name##_list_free(name##_list_t **l) { _z_list_free(l, name##_elem_free); }

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions src/net/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,16 @@ z_result_t _z_reopen(_z_session_rc_t *zn) {
}

#if Z_FEATURE_MULTI_THREAD == 1
// TODO: currnetly we can come to reopen only from task, so we can restart them
// but we have no original attributes (which currently in all known cases is default
// TODO (sashacmc): currnetly we can come to reopen only from task, so we can restart them
// but we have no original attributes (which currently for most cases is default)
_zp_start_lease_task(_Z_RC_IN_VAL(zn), NULL);
_zp_start_read_task(_Z_RC_IN_VAL(zn), NULL);
#endif // Z_FEATURE_MULTI_THREAD == 1

if (ret == _Z_RES_OK && !_z_network_message_list_is_empty(zs->_decalaration_cache)) {
_z_network_message_list_t *iter = zs->_decalaration_cache;
while (iter != NULL) {
_z_network_message_t *n_msg = _z_network_message_list_head(zs->_decalaration_cache);
_z_network_message_t *n_msg = _z_network_message_list_head(iter);
ret = _z_send_n_msg(_Z_RC_IN_VAL(zn), n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK);
if (ret != _Z_RES_OK) {
_Z_DEBUG("Send message during reopen failed: %i", ret);
Expand All @@ -209,7 +209,7 @@ void _z_cache_declaration(_z_session_t *zs, const _z_network_message_t *n_msg) {
if (_z_config_is_empty(&zs->_config)) {
return;
}
zs->_decalaration_cache = _z_network_message_list_push(zs->_decalaration_cache, _z_n_msg_clone(n_msg));
zs->_decalaration_cache = _z_network_message_list_push_back(zs->_decalaration_cache, _z_n_msg_clone(n_msg));
}

void _z_prune_declaration(_z_session_t *zs, const _z_network_message_t *n_msg) {
Expand Down
1 change: 0 additions & 1 deletion tests/connection_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def test_restart(router_command, client_command, timeout):

print("Start router...")
run_background(router_command, None, router_process_list)
time.sleep(timeout)

if wait_message(client_output, CONNECT_MESSAGE):
print("Connection restored successfully.")
Expand Down

0 comments on commit ef0ebb8

Please sign in to comment.