tgetlistenfd: on setsockopt failure it could return an invalid/closed fd - geomyidae - A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log
Files
Refs
README
LICENSE
---
commit cb9b6b70dbc6b33cc29364ba31023ffeb0579085
parent feed37adc1b23cac513b5d2a17bda4e2ffc77c81
Author: Hiltjo Posthuma 
Date:   Wed, 29 Aug 2018 20:18:50 +0200

getlistenfd: on setsockopt failure it could return an invalid/closed fd

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
  main.c                              |       1 +

1 file changed, 1 insertion(+), 0 deletions(-)
---
diff --git a/main.c b/main.c
t@@ -311,6 +311,7 @@ getlistenfd(struct addrinfo *hints, char *bindip, char *port)
                 if (setsockopt(listfd, SOL_SOCKET, SO_REUSEADDR, &on,
                                         sizeof(on)) < 0) {
                         close(listfd);
+                        listfd = -1;
                         break;
                 }