From 9e4ccfbe5285ad63d30aa649a8580173c3bfed29 Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Tue, 13 Aug 2024 11:49:20 +0300 Subject: [PATCH] Fix rcv-timeout issue because of Nread timeout --- src/iperf_api.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index daa157cac..0d6adef13 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -2000,8 +2000,14 @@ iperf_recv_mt(struct iperf_stream *sp) i_errno = IESTREAMREAD; return r; } - test->bytes_received += r; - ++test->blocks_received; + + /* Collect statistics only if receive did not timeout (e.g. `Nread()` may timeout). + * This is also important for `--rcv-timeout` to work properly. + */ + if (r > 0) { + test->bytes_received += r; + ++test->blocks_received; + } return 0; }