From a509a4821c4fb2ad2c94c8a65130f0f7cecde2c6 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 27 Dec 2023 09:57:43 +0100 Subject: [PATCH] fix: stop unicast read task if close message received --- include/zenoh-pico/utils/result.h | 2 ++ src/transport/unicast/rx.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/zenoh-pico/utils/result.h b/include/zenoh-pico/utils/result.h index 514473947..a3ff7c1d6 100644 --- a/include/zenoh-pico/utils/result.h +++ b/include/zenoh-pico/utils/result.h @@ -65,6 +65,8 @@ typedef enum { _Z_ERR_SYSTEM_TASK_FAILED = -79, _Z_ERR_SYSTEM_OUT_OF_MEMORY = -78, + _Z_ERR_CONNECTION_CLOSED = -77, + _Z_ERR_GENERIC = -128 } _z_res_t; diff --git a/src/transport/unicast/rx.c b/src/transport/unicast/rx.c index c1e3faa2d..f925600f7 100644 --- a/src/transport/unicast/rx.c +++ b/src/transport/unicast/rx.c @@ -96,6 +96,8 @@ int8_t _z_unicast_recv_t_msg(_z_transport_unicast_t *ztu, _z_transport_message_t } int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg) { + int8_t ret = _Z_RES_OK; + switch (_Z_MID(t_msg->_header)) { case _Z_MID_T_FRAME: { _Z_INFO("Received Z_FRAME message\n"); @@ -190,6 +192,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans case _Z_MID_T_CLOSE: { _Z_INFO("Closing session as requested by the remote peer\n"); + ret = _Z_ERR_CONNECTION_CLOSED; break; } @@ -199,7 +202,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans } } - return _Z_RES_OK; + return ret; } #else int8_t _z_unicast_recv_t_msg(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg) {