From 35342a52c1902341799ef2bc903e00361914100b Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 29 Nov 2023 11:40:01 +0100 Subject: [PATCH] fix: add missing close socket function --- include/zenoh-pico/system/link/raweth.h | 1 + src/system/unix/link/raweth.c | 8 ++++++++ src/transport/raweth/link.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/zenoh-pico/system/link/raweth.h b/include/zenoh-pico/system/link/raweth.h index 41c6738fa..afc1c7506 100644 --- a/include/zenoh-pico/system/link/raweth.h +++ b/include/zenoh-pico/system/link/raweth.h @@ -58,6 +58,7 @@ int8_t _z_get_smac_raweth(_z_raweth_socket_t *resock); int8_t _z_open_raweth(_z_sys_net_socket_t *sock); size_t _z_send_raweth(const _z_sys_net_socket_t *sock, const void *buff, size_t buff_len); size_t _z_receive_raweth(const _z_sys_net_socket_t *sock, void *buff, size_t buff_len, _z_bytes_t *addr); +int8_t _z_close_raweth(_z_sys_net_socket_t *sock); #endif diff --git a/src/system/unix/link/raweth.c b/src/system/unix/link/raweth.c index e19178bea..de4d4afc3 100644 --- a/src/system/unix/link/raweth.c +++ b/src/system/unix/link/raweth.c @@ -85,6 +85,14 @@ int8_t _z_open_raweth(_z_sys_net_socket_t *sock) { return ret; } +int8_t _z_close_raweth(_z_sys_net_socket_t *sock) { + int8_t ret = _Z_RES_OK; + if (close(sock->_fd) != 0) { + ret = _Z_ERR_GENERIC; + } + return ret; +} + size_t _z_send_raweth(const _z_sys_net_socket_t *sock, const void *buff, size_t buff_len) { // Send data ssize_t wb = write(sock->_fd, buff, buff_len); diff --git a/src/transport/raweth/link.c b/src/transport/raweth/link.c index 23cf31156..162563567 100644 --- a/src/transport/raweth/link.c +++ b/src/transport/raweth/link.c @@ -78,7 +78,7 @@ static int8_t _z_f_link_open_raweth(_z_link_t *self) { static int8_t _z_f_link_listen_raweth(_z_link_t *self) { return _z_f_link_open_raweth(self); } -static void _z_f_link_close_raweth(_z_link_t *self) { _ZP_UNUSED(self); } +static void _z_f_link_close_raweth(_z_link_t *self) { _z_close_raweth(&self->_socket._raweth._sock); } static void _z_f_link_free_raweth(_z_link_t *self) { _ZP_UNUSED(self); }