tests/echo_srv: make the main server logic resilient to ECONNABORTED from accept()
authorStefan Metzmacher <metze@samba.org>
Fri, 5 Feb 2021 11:22:47 +0000 (12:22 +0100)
committerAndreas Schneider <asn@samba.org>
Fri, 5 Feb 2021 13:11:31 +0000 (14:11 +0100)
That should fix a race where the connect() directly followed by close()
in test_thread_echo_tcp_connect will cause the echo_srv to terminate
early, which results in connect() returning ECONNREFUSED in for other
threads.

This mainly happens on FreeBSD, but it can also happen on Linux.

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

index 87c85f74b22a96ca54878de502b98c3d5e123141..0aefa9aa9825f76c2e90535a52adc5eba90afc5a 100644 (file)
@@ -538,6 +538,9 @@ static void echo_tcp(int sock)
 
     while (1) {
         s = accept(sock, &addr.sa.s, &addr.sa_socklen);
+        if (s == -1 && errno == ECONNABORTED) {
+            continue;
+        }
         if (s == -1) {
             perror("accept");
             goto done;