Should probably set non-blocking socket options before calling listen
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 May 2014 23:21:39 +0000 (00:21 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 2 May 2014 23:21:46 +0000 (00:21 +0100)
src/main/listen.c

index fee2686..3cb502e 100644 (file)
@@ -2487,15 +2487,6 @@ static int listen_bind(rad_listen_t *this)
 #ifdef WITH_TCP
        if (sock->proto == IPPROTO_TCP) {
                /*
-                *      Allow a backlog of 8 listeners
-                */
-               if (listen(this->fd, 8) < 0) {
-                       close(this->fd);
-                       ERROR("Failed in listen(): %s", fr_syserror(errno));
-                       return -1;
-               }
-
-               /*
                 *      If there are hard-coded worker threads, they're blocking.
                 *
                 *      Otherwise, they're non-blocking.
@@ -2506,6 +2497,15 @@ static int listen_bind(rad_listen_t *this)
                              fr_syserror(errno));
                        return -1;
                }
+
+               /*
+                *      Allow a backlog of 8 listeners
+                */
+               if (listen(this->fd, 8) < 0) {
+                       close(this->fd);
+                       ERROR("Failed in listen(): %s", fr_syserror(errno));
+                       return -1;
+               }
        }
 #endif