From e557bab0dcaf35f003fa755b74e4c80000e05e42 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 9 Dec 2020 17:16:40 +0000 Subject: Get rid of webipc.h and DJBUNIX_FLAG_* Decent semantic header separation is hard. It's always an ongoing process. Here socket.h always included webipc.h for listen(), and webipc.h always included djbunix.h for socket_internal() and socketpair_internal(). That's ugh. Just move all the socket stuff into one socket header. Of course, djbunix.h is still needed most of the time for fd_close() and other operations on fds, but those are generic anyway. Also, O_CLOEXEC exists everywhere now, so we can use it as well as O_NONBLOCK instead of redefining the flags in djbunix.h. --- src/libstddjb/ipc_accept.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/libstddjb/ipc_accept.c') diff --git a/src/libstddjb/ipc_accept.c b/src/libstddjb/ipc_accept.c index b0b44c3..9d5d82c 100644 --- a/src/libstddjb/ipc_accept.c +++ b/src/libstddjb/ipc_accept.c @@ -6,9 +6,11 @@ #include #include #include +#include + #include #include -#include +#include int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int options) { @@ -18,15 +20,15 @@ int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int opti memset(&sa, 0, dummy) ; do #ifdef SKALIBS_HASACCEPT4 - fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; + fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd == -1) && (errno == EINTR)) ; if (fd == -1) return -1 ; #ifndef SKALIBS_HASACCEPT4 - if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) - || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) + if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) + || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; -- cgit v1.3.1