prevent SO_REUSEPORT errors on systems that do not support them; fixes #2208
Costa Tsaousis (ktsaou) committed
Sep 7, 2017 at 23:34 UTC
262da64139b7be8fc08224d764ef048010611165
1 file changed
+2
-1
src/socket.c
+2
-1
@@ -46,9 +46,10 @@ int sock_setreuse(int fd, int reuse) {
46
47
int sock_setreuse_port(int fd, int reuse) {
48
int ret = -1;
49
+
50
#ifdef SO_REUSEPORT
51
ret = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(reuse));
51
- if(ret == -1)
52
+ if(ret == -1 && errno != ENOPROTOOPT)
53
error("failed to set SO_REUSEPORT on socket %d", fd);
54
#endif
55