Skip to content

Commit

Permalink
fix: stop unicast read task if close message received
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Dec 27, 2023
1 parent 7a681f7 commit a509a48
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/zenoh-pico/utils/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 4 additions & 1 deletion src/transport/unicast/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit a509a48

Please sign in to comment.