diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-09 17:16:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-09 17:16:40 +0000 |
commit | e557bab0dcaf35f003fa755b74e4c80000e05e42 (patch) | |
tree | 3bc4d8aeb04117b324f1b9b182c923e259a657c7 /src/libstddjb/socket_accept4.c | |
parent | 86312d159d55e99db5a5c82d9c50f31a1fe28199 (diff) | |
download | skalibs-e557bab0dcaf35f003fa755b74e4c80000e05e42.tar.xz |
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.
Diffstat (limited to 'src/libstddjb/socket_accept4.c')
-rw-r--r-- | src/libstddjb/socket_accept4.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstddjb/socket_accept4.c b/src/libstddjb/socket_accept4.c index 40dff91..2016777 100644 --- a/src/libstddjb/socket_accept4.c +++ b/src/libstddjb/socket_accept4.c @@ -6,6 +6,8 @@ #include <netinet/in.h> #include <string.h> #include <errno.h> +#include <fcntl.h> + #include <skalibs/uint16.h> #include <skalibs/djbunix.h> #include <skalibs/socket.h> @@ -17,15 +19,15 @@ int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int optio int fd ; 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 < 0) && (errno == EINTR)) ; if (fd < 0) 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 ; |