summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2021-02-05 12:22:47 +0100
committerAndreas Schneider <asn@samba.org>2021-02-05 14:11:31 +0100
commitfa7a9b7ab5edf3ca986979b9cdaa08deae3d9308 (patch)
treeca5a775092545e4349fbd7f356d1721ece859910
parentcd51d80946cdc938cea905b2242144f08ef2fec7 (diff)
downloadsocket_wrapper-fa7a9b7ab5edf3ca986979b9cdaa08deae3d9308.tar.gz
socket_wrapper-fa7a9b7ab5edf3ca986979b9cdaa08deae3d9308.tar.xz
socket_wrapper-fa7a9b7ab5edf3ca986979b9cdaa08deae3d9308.zip
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 <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r--tests/echo_srv.c3
1 files changed, 3 insertions, 0 deletions
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;