]> git.pond.sub.org Git - empserver/commitdiff
Ignore error setting socket option SO_REUSEADDR
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 7 Apr 2013 17:14:57 +0000 (19:14 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 8 May 2013 04:57:56 +0000 (06:57 +0200)
Shouldn't fail.  If it fails, but bind() works, the failure doesn't
matter.  If bind() fails, we can just as well report that failure
instead of setsockopt()'s.

src/lib/gen/tcp_listen.c

index 6dd0a5e4eafa990ee0ccc45d0ec9b1e58a0d423e..41df7ac0d236b2e7d63447d2050380c66f63fa7c 100644 (file)
@@ -81,8 +81,7 @@ tcp_listen(char *host, char *serv, size_t *addrlenp)
        if (fd < 0)
            continue;           /* error, try next one */
 
-       if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
-           cant_listen(host, serv, strerror(errno));
+       setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
        if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0)
            break;              /* success */
 
@@ -127,8 +126,7 @@ tcp_listen(char *host, char *serv, size_t *addrlenp)
     }
     if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
        cant_listen(host, serv, strerror(errno));
-    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
-       cant_listen(host, serv, strerror(errno));
+    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
     if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
        cant_listen(host, serv, strerror(errno));
     if (listen(fd, SOMAXCONN) < 0)