From ef0ebb8fa8e9c7b27c6abb619209bb2937d991b1 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Fri, 13 Dec 2024 12:33:05 +0100 Subject: [PATCH] Fix multiply declaration restore --- include/zenoh-pico/collections/list.h | 37 ++++++++++++++------------- src/net/session.c | 8 +++--- tests/connection_restore.py | 1 - 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/zenoh-pico/collections/list.h b/include/zenoh-pico/collections/list.h index 590d0f32d..22b9f8d3a 100644 --- a/include/zenoh-pico/collections/list.h +++ b/include/zenoh-pico/collections/list.h @@ -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 diff --git a/src/net/session.c b/src/net/session.c index 644c0b822..cf83e4867 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -181,8 +181,8 @@ 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 @@ -190,7 +190,7 @@ z_result_t _z_reopen(_z_session_rc_t *zn) { 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); @@ -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) { diff --git a/tests/connection_restore.py b/tests/connection_restore.py index 35f00e947..239c46205 100644 --- a/tests/connection_restore.py +++ b/tests/connection_restore.py @@ -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.")