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_bind_reuse_lock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libstddjb/ipc_bind_reuse_lock.c') diff --git a/src/libstddjb/ipc_bind_reuse_lock.c b/src/libstddjb/ipc_bind_reuse_lock.c index b1bccfd..c872e44 100644 --- a/src/libstddjb/ipc_bind_reuse_lock.c +++ b/src/libstddjb/ipc_bind_reuse_lock.c @@ -8,7 +8,7 @@ #include #include -#include +#include int ipc_bind_reuse_lock (int s, char const *p, int *fdlock) { @@ -24,8 +24,10 @@ int ipc_bind_reuse_lock (int s, char const *p, int *fdlock) r = fd_lock(fd, 1, 1) ; if (r < 0) return -1 ; if (!r) return (errno = EBUSY, -1) ; + r = errno ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; - unlink(p) ; + errno = r ; + unlink_void(p) ; if (ipc_bind(s, p) < 0) return -1 ; *fdlock = fd ; return 0 ; -- cgit v1.3.1