From 0fdda50c64adc6f94ead9edeb3776f69abde8051 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Fri, 3 Jan 2014 10:06:16 -0800 Subject: [PATCH] Fix a deadlock leading to a hang in -R mode. In -R mode, the test consists of the server sending to the client until the client tells it to stop by setting the test state to TEST_END via the control socket. However once the client changes the test state, it stopped reading the incoming test data from the server. In many (but not all) scenarios this could result in the server filling up its send window (thus blocking on writes) before the TEST_END message arrived from the client. At this point the server was hanging waiting for the client to drain its data connection(s), and the client was waiting for the server to send a state change message for EXCHANGE_RESULTS. Bump copyright date while here. This fix handles at least part of... Issue: 129 (iperf3 hangs with -R and -Z flags) --- src/iperf_client_api.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index 5e6db4e..f2e2a4e 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011, The Regents of the University of California, + * Copyright (c) 2009-2014, The Regents of the University of California, * through Lawrence Berkeley National Laboratory (subject to receipt of any * required approvals from the U.S. Dept. of Energy). All rights reserved. * @@ -450,6 +450,15 @@ iperf_run_client(struct iperf_test * test) } } } + // If we're in reverse mode, continue draining the data + // connection(s) even if test is over. This prevents a + // deadlock where the server side fills up its pipe(s) + // and gets blocked, so it can't receive state changes + // from the client side. + else if (test->reverse && test->state == TEST_END) { + if (iperf_recv(test, &read_set) < 0) + return -1; + } } if (test->json_output) {