From 6bb24296ff0ccaa3783a6cb973dc758a56c81bd5 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 19 Dec 2024 12:19:56 +0100 Subject: [PATCH] Improve reopen errors handling --- src/net/session.c | 11 ++++++++--- src/system/rpi_pico/system.c | 1 - src/transport/unicast/lease.c | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/net/session.c b/src/net/session.c index d00750a61..9374e9131 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -183,14 +183,19 @@ z_result_t _z_reopen(_z_session_rc_t *zn) { z_sleep_s(1); continue; } else { - _Z_ERROR("Reopen failed: %i", ret); return ret; } } #if Z_FEATURE_MULTI_THREAD == 1 - _zp_start_lease_task(zs, zs->_lease_task_attr); - _zp_start_read_task(zs, zs->_read_task_attr); + ret = _zp_start_lease_task(zs, zs->_lease_task_attr); + if (ret != _Z_RES_OK) { + return ret; + } + ret = _zp_start_read_task(zs, zs->_read_task_attr); + if (ret != _Z_RES_OK) { + return ret; + } #endif // Z_FEATURE_MULTI_THREAD == 1 if (ret == _Z_RES_OK && !_z_network_message_list_is_empty(zs->_decalaration_cache)) { diff --git a/src/system/rpi_pico/system.c b/src/system/rpi_pico/system.c index 26f3b011a..3cf48af62 100644 --- a/src/system/rpi_pico/system.c +++ b/src/system/rpi_pico/system.c @@ -104,7 +104,6 @@ z_result_t _z_task_join(_z_task_t *task) { z_result_t _z_task_detach(_z_task_t *task) { _ZP_UNUSED(task); - assert(false); return _Z_ERR_GENERIC; } diff --git a/src/transport/unicast/lease.c b/src/transport/unicast/lease.c index dd83ed20f..233ab0053 100644 --- a/src/transport/unicast/lease.c +++ b/src/transport/unicast/lease.c @@ -47,7 +47,10 @@ static void _zp_unicast_failed(_z_transport_unicast_t *ztu) { #if Z_FEATURE_AUTO_RECONNECT == 1 _z_session_rc_ref_t *zs = ztu->_common._session; - _z_reopen(zs); + z_result_t ret = _z_reopen(zs); + if (ret != _Z_RES_OK) { + _Z_ERROR("Reopen failed: %i", ret); + } #endif }