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/socket_internal.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/libstddjb/socket_internal.c') diff --git a/src/libstddjb/socket_internal.c b/src/libstddjb/socket_internal.c index 848b156..852f323 100644 --- a/src/libstddjb/socket_internal.c +++ b/src/libstddjb/socket_internal.c @@ -3,13 +3,16 @@ #include #include #include +#include + #include +#include #ifdef SKALIBS_HASACCEPT4 int socket_internal (int domain, int type, int protocol, unsigned int flags) { - return socket(domain, type | ((flags & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((flags & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0), protocol) ; + return socket(domain, type | ((flags & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((flags & O_CLOEXEC) ? SOCK_CLOEXEC : 0), protocol) ; } #else @@ -18,8 +21,8 @@ int socket_internal (int domain, int type, int protocol, unsigned int flags) { int s = socket(domain, type, protocol) ; if (s == -1) return -1 ; - if ((((flags & DJBUNIX_FLAG_NB) ? ndelay_on(s) : ndelay_off(s)) < 0) - || (((flags & DJBUNIX_FLAG_COE) ? coe(s) : uncoe(s)) < 0)) + if ((((flags & O_NONBLOCK) ? ndelay_on(s) : ndelay_off(s)) < 0) + || (((flags & O_CLOEXEC) ? coe(s) : uncoe(s)) < 0)) { fd_close(s) ; return -1 ; -- cgit v1.2.3