From 7ec97df3ee8edfd102fe573eaa61cf4e5c6284cb Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 27 Sep 2024 22:27:01 -0600 Subject: wip fixes --- libnetio/include/libnetio/netio.h | 20 ++++++++++++++++++++ libnetio/netio.h | 18 ------------------ libnetio/netio_posix.c | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) create mode 100644 libnetio/include/libnetio/netio.h delete mode 100644 libnetio/netio.h (limited to 'libnetio') diff --git a/libnetio/include/libnetio/netio.h b/libnetio/include/libnetio/netio.h new file mode 100644 index 0000000..9383c54 --- /dev/null +++ b/libnetio/include/libnetio/netio.h @@ -0,0 +1,20 @@ +#ifndef _NETIO_H_ +#define _NETIO_H_ + +#include /* for bool */ +#include /* for uint16_t */ +#include /* for size_t */ +#include /* for ssize_t */ + +/** Return socket-fd on success, -errno on error. */ +int netio_listen(uint16_t port); +/** Return connection-fd on success, -errno on error. */ +int netio_accept(int sock); +/** Return bytes-read on success, 0 on EOF, -errno on error; a short read is *not* an error. */ +ssize_t netio_read(int conn, void *buf, size_t count); +/** Return `count` on success, -errno on error; a short write *is* an error. */ +ssize_t netio_write(int conn, void *buf, size_t count); +/** Return 0 on success, -errno on error. */ +int netio_close(int conn, bool rd, bool wr); + +#endif /* _NETIO_H_ */ diff --git a/libnetio/netio.h b/libnetio/netio.h deleted file mode 100644 index 8497330..0000000 --- a/libnetio/netio.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _NETIO_H_ -#define _NETIO_H_ - -#include /* for bool */ -#include /* for size_t, ssize_t, uint16_t */ - -/** Return socket-fd on success, -errno on error. */ -int netio_listen(uint16_t port); -/** Return connection-fd on success, -errno on error. */ -int netio_accept(int sock); -/** Return bytes-read on success, 0 on EOF, -errno on error; a short read is *not* an error. */ -ssize_t netio_read(int conn, void *buf, size_t count); -/** Return `count` on success, -errno on error; a short write *is* an error. */ -ssize_t netio_write(int conn, void *buf, size_t count); -/** Return 0 on success, -errno on error. */ -int netio_close(int conn, bool rd, bool wr); - -#endif /* _NETIO_H_ */ diff --git a/libnetio/netio_posix.c b/libnetio/netio_posix.c index 133b226..2cc6be4 100644 --- a/libnetio/netio_posix.c +++ b/libnetio/netio_posix.c @@ -134,7 +134,7 @@ int netio_accept(int sock) { * while waiting for us to accept(). */ for (;;) { #if CONFIG_NETIO_ISLINUX - cr_sema_wait(&sock->accept_waiters); + cr_sema_wait(&socket_table[sock].accept_waiters); #endif int conn = accept(socket_table[sock].fd, NULL, NULL); if (conn < 0) { -- cgit v1.2.3-2-g168b