Skip to content

Commit

Permalink
Don't try to set SO_REUSEADDR on sockets of AF_UNIX (valkey-io#451)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
panjf2000 authored May 7, 2024
1 parent ba9dd7b commit cde8ec1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/anet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit cde8ec1

Please sign in to comment.