Skip to content

Commit

Permalink
fix: add missing close socket function
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Nov 29, 2023
1 parent a019b14 commit 35342a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/zenoh-pico/system/link/raweth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/system/unix/link/raweth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/transport/raweth/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down

0 comments on commit 35342a5

Please sign in to comment.