From fa7a9b7ab5edf3ca986979b9cdaa08deae3d9308 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 5 Feb 2021 12:22:47 +0100 Subject: [PATCH] tests/echo_srv: make the main server logic resilient to ECONNABORTED from accept() 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 Reviewed-by: Andreas Schneider --- tests/echo_srv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/echo_srv.c b/tests/echo_srv.c index 87c85f7..0aefa9a 100644 --- a/tests/echo_srv.c +++ b/tests/echo_srv.c @@ -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; -- 2.34.1