]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: test-http-payload: server: Fix asynchronous listening.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Mar 2018 20:34:11 +0000 (21:34 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 25 May 2018 20:46:29 +0000 (22:46 +0200)
The listening socket was blocking and the io handler only accepted one connection per run.

src/lib-http/test-http-payload.c

index 77043ab54c2ac740d1b28d96d8cbbaf7043add2d..e588a3436e567b909bc703b5ebcc0424bea55b15 100644 (file)
@@ -588,15 +588,18 @@ static void client_accept(void *context ATTR_UNUSED)
 {
        int fd;
 
-       /* accept new client */
-       fd = net_accept(fd_listen, NULL, NULL);
-       if (fd == -1)
-               return;
-       if (fd == -2) {
-               i_fatal("test server: accept() failed: %m");
-       }
+       for (;;) {
+               /* accept new client */
+               if ((fd=net_accept(fd_listen, NULL, NULL)) < 0) {
+                       if (errno == EAGAIN)
+                               break;
+                       if (errno == ECONNABORTED)
+                               continue;
+                       i_fatal("test server: accept() failed: %m");
+               }
 
-       client_init(fd);
+               client_init(fd);
+       }
 }
 
 /* */
@@ -1294,6 +1297,7 @@ static void test_open_server_fd(void)
                i_fatal("listen(%s:%u) failed: %m",
                        net_ip2addr(&bind_ip), bind_port);
        }
+       net_set_nonblock(fd_listen, TRUE);
 }
 
 static void test_server_kill(void)