summaryrefslogtreecommitdiffhomepage
path: root/src/sock.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-11-08 11:41:35 +0100
committerMichael Adam <obnox@samba.org>2013-11-09 13:34:33 +0100
commitb41d140984604e31f94e680257bfedc9893eb181 (patch)
treee21aff5ea1c423d5bc4fd3a839223f5431b957f7 /src/sock.c
parent5392e9829c186b5d09f135c7f379f18f0738745a (diff)
sock: in listen_sock(), detect and log failure to call setsockopt()
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src/sock.c')
-rw-r--r--src/sock.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sock.c b/src/sock.c
index b95f69c..097af25 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -192,6 +192,7 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
for (rp = result; rp != NULL; rp = rp->ai_next) {
int listenfd;
+ int lret;
listenfd = socket (rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
@@ -202,8 +203,15 @@ int listen_sock (const char *addr, uint16_t port, vector_t listen_fds)
continue;
}
- setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
- sizeof (on));
+ lret = setsockopt (listenfd, SOL_SOCKET, SO_REUSEADDR, &on,
+ sizeof (on));
+ if (lret != 0) {
+ log_message (LOG_ERR,
+ "setsockopt failed to set SO_REUSEADDR: "
+ "%s", strerror(errno));
+ close(listenfd);
+ continue;
+ }
if (bind(listenfd, rp->ai_addr, rp->ai_addrlen) != 0) {
close (listenfd);