diff --git a/src/iperf_api.c b/src/iperf_api.c index dad864b..64f83fb 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1539,7 +1539,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP) double seconds; uint64_t bits_per_second; - if (sp->test->done || sp->test->settings->rate == 0 || sp->test->settings->burst != 0) + if (sp->test->done || sp->test->settings->rate == 0) return; iperf_time_diff(&sp->result->start_time_fixed, nowP, &temp_time); seconds = iperf_time_in_secs(&temp_time); @@ -1598,6 +1598,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) register int multisend, r, streams_active; register struct iperf_stream *sp; struct iperf_time now; + int no_throttle_check; /* Can we do multisend mode? */ if (test->settings->burst != 0) @@ -1607,8 +1608,11 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) else multisend = 1; /* nope */ + /* Should bitrate throttle be checked for every send */ + no_throttle_check = test->settings->rate != 0 && test->settings->burst == 0; + for (; multisend > 0; --multisend) { - if (test->settings->rate != 0 && test->settings->burst == 0) + if (no_throttle_check) iperf_time_now(&now); streams_active = 0; SLIST_FOREACH(sp, &test->streams, streams) { @@ -1623,7 +1627,8 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) streams_active = 1; test->bytes_sent += r; ++test->blocks_sent; - iperf_check_throttle(sp, &now); + if (no_throttle_check) + iperf_check_throttle(sp, &now); if (multisend > 1 && test->settings->bytes != 0 && test->bytes_sent >= test->settings->bytes) break; if (multisend > 1 && test->settings->blocks != 0 && test->blocks_sent >= test->settings->blocks) @@ -1633,7 +1638,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) if (!streams_active) break; } - if (test->settings->burst != 0) { + if (!no_throttle_check) { /* Throttle check if was not checked for each send */ iperf_time_now(&now); SLIST_FOREACH(sp, &test->streams, streams) if (sp->sender)