From cde8ec1b414e5da00ee90cbaf21c1c7ae37e93e9 Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Wed, 8 May 2024 01:25:26 +0800 Subject: [PATCH] Don't try to set SO_REUSEADDR on sockets of AF_UNIX (#451) Despite the fact that SO_REUSEADDR can be set on a Unix domain socket via setsockopt() without reporting an error, SO_REUSEADDR was actually created for ipv4/ipv6 and it's not supported for sockets of AF_UNIX. Therefore, setting this option on a Unix domain socket does nothing but costs one extra system call. Signed-off-by: Andy Pan --- src/anet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anet.c b/src/anet.c index d90af6d9e..75471abd2 100644 --- a/src/anet.c +++ b/src/anet.c @@ -616,7 +616,7 @@ int anetUnixServer(char *err, char *path, mode_t perm, int backlog) } int type = SOCK_STREAM; - int flags = ANET_SOCKET_CLOEXEC | ANET_SOCKET_NONBLOCK | ANET_SOCKET_REUSEADDR; + int flags = ANET_SOCKET_CLOEXEC | ANET_SOCKET_NONBLOCK; if ((s = anetCreateSocket(err,AF_LOCAL,type,0,flags)) == ANET_ERR) return ANET_ERR;