diff --git a/include/zenoh-pico/net/session.h b/include/zenoh-pico/net/session.h index 5a50ac308..c4326a397 100644 --- a/include/zenoh-pico/net/session.h +++ b/include/zenoh-pico/net/session.h @@ -38,6 +38,8 @@ extern "C" { typedef struct _z_session_t { #if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_t _mutex_inner; + z_task_attr_t *_lease_task_attr; + z_task_attr_t *_read_task_attr; #endif // Z_FEATURE_MULTI_THREAD == 1 // Zenoh-pico is considering a single transport per session. diff --git a/src/net/session.c b/src/net/session.c index 0a8b03b4b..0b494944e 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -174,25 +174,27 @@ z_result_t _z_reopen(_z_session_rc_t *zn) { do { ret = _z_open(zn, &zs->_config, &zs->_local_zid); - // TODO(sashacmc): break on fatal error, and add timeout config if (ret != _Z_RES_OK) { - _Z_DEBUG("Reopen failed: %i, next try in 1s", ret); - z_sleep_s(1); - continue; + if (ret == _Z_ERR_TRANSPORT_OPEN_FAILED || ret == _Z_ERR_SCOUT_NO_RESULTS) { + _Z_DEBUG("Reopen failed, next try in 1s"); + z_sleep_s(1); + continue; + } else { + _Z_ERROR("Reopen failed: %i", ret); + return ret; + } } #if Z_FEATURE_MULTI_THREAD == 1 - // 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); + _zp_start_lease_task(zs, zs->_lease_task_attr); + _zp_start_read_task(zs, zs->_read_task_attr); #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(iter); - ret = _z_send_n_msg(_Z_RC_IN_VAL(zn), n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK); + ret = _z_send_n_msg(zs, n_msg, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK); if (ret != _Z_RES_OK) { _Z_DEBUG("Send message during reopen failed: %i", ret); continue; @@ -326,6 +328,8 @@ z_result_t _zp_start_read_task(_z_session_t *zn, z_task_attr_t *attr) { // Free task if operation failed if (ret != _Z_RES_OK) { z_free(task); + } else { + zn->_read_task_attr = attr; } return ret; } @@ -355,6 +359,8 @@ z_result_t _zp_start_lease_task(_z_session_t *zn, z_task_attr_t *attr) { // Free task if operation failed if (ret != _Z_RES_OK) { z_free(task); + } else { + zn->_lease_task_attr = attr; } return ret; } diff --git a/src/protocol/definitions/transport.c b/src/protocol/definitions/transport.c index 69b1cc502..7bdfd9d85 100644 --- a/src/protocol/definitions/transport.c +++ b/src/protocol/definitions/transport.c @@ -41,7 +41,6 @@ void _z_t_msg_close_clear(_z_t_msg_close_t *msg) { (void)(msg); } void _z_t_msg_keep_alive_clear(_z_t_msg_keep_alive_t *msg) { (void)(msg); } void _z_t_msg_frame_clear(_z_t_msg_frame_t *msg) { - // TODO (sashacmc): make in more correct way if (!msg->_messages._aliased) { _z_network_message_svec_clear(&msg->_messages); } diff --git a/src/session/rx.c b/src/session/rx.c index eb5ddf6e4..9d44fcc45 100644 --- a/src/session/rx.c +++ b/src/session/rx.c @@ -164,7 +164,6 @@ z_result_t _z_handle_network_message(_z_session_rc_t *zsrc, _z_zenoh_message_t * } } } - // TODO (sashacmc): why it was removed??? _z_msg_clear(msg); return ret; }