aboutsummaryrefslogtreecommitdiff
path: root/src/iperf_tcp.c
diff options
context:
space:
mode:
authorBruce A. Mah <bmah@kitchenlab.org>2018-02-23 15:36:25 -0800
committerGitHub <noreply@github.com>2018-02-23 15:36:25 -0800
commitc0055199b5fc006166d03abb0106448c56aa2bb7 (patch)
treeb66cbcad69a3164026d27ff29684604fc12f8cdb /src/iperf_tcp.c
parent8740c8cf8e18bfac1590ee84717f93bf7f84cc86 (diff)
downloadiperf3-c0055199b5fc006166d03abb0106448c56aa2bb7.tar.gz
Fix issue 692 (#705)
Don't count data for tests received after the end of a test. This prevents is from reporting an incorrect number of bytes received at the end of the test, which doesn't match up with the sum of the data received during the test intervals. Log late receives if debugging mode enabled. Fixes #692.
Diffstat (limited to 'src/iperf_tcp.c')
-rw-r--r--src/iperf_tcp.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c
index 3d000b7..e16203a 100644
--- a/src/iperf_tcp.c
+++ b/src/iperf_tcp.c
@@ -60,8 +60,15 @@ iperf_tcp_recv(struct iperf_stream *sp)
if (r < 0)
return r;
- sp->result->bytes_received += r;
- sp->result->bytes_received_this_interval += r;
+ /* Only count bytes received while we're in the correct state. */
+ if (sp->test->state == TEST_RUNNING) {
+ sp->result->bytes_received += r;
+ sp->result->bytes_received_this_interval += r;
+ }
+ else {
+ if (sp->test->debug)
+ printf("Late receive, state = %d\n", sp->test->state);
+ }
return r;
}