tests/echo_srv: allow more than once tcp connection at a time
authorStefan Metzmacher <metze@samba.org>
Fri, 5 Feb 2021 14:41:27 +0000 (15:41 +0100)
committerAndreas Schneider <asn@samba.org>
Mon, 8 Feb 2021 18:29:57 +0000 (19:29 +0100)
We should not wait for the last connection to disconnect,
there would not be any reason to use fork at all.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
tests/echo_srv.c

index 0aefa9aa9825f76c2e90535a52adc5eba90afc5a..fbb6637a6a9deb4e2778b7952f273fb316b9eae8 100644 (file)
@@ -537,6 +537,7 @@ static void echo_tcp(int sock)
     pid_t pid;
 
     while (1) {
+        waitpid(-1, NULL, WNOHANG);
         s = accept(sock, &addr.sa.s, &addr.sa_socklen);
         if (s == -1 && errno == ECONNABORTED) {
             continue;
@@ -575,7 +576,6 @@ static void echo_tcp(int sock)
             close(s);
             exit(0);
         }
-        waitpid(-1, NULL, 0);
         close(s);
     }