Skip to content

Commit 7e58c53

Browse files
authored
Merge pull request #1821 from davidBar-On/issue-1820-bitrate-ignored-with-burst
Fix issue that bitrate is ignored when burst is set (with Nanosleep)
2 parents d8af312 + d9333ca commit 7e58c53

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/iperf_api.c

+19-2
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)
19221922
delta_bits = bits_sent - (seconds * sp->test->settings->rate);
19231923
// Calclate time until next data send is required
19241924
time_to_green_light = (SEC_TO_NS * delta_bits / sp->test->settings->rate);
1925-
// Whether shouuld wait before next send
1925+
// Whether should wait before next send
19261926
if (time_to_green_light >= 0) {
19271927
#if defined(HAVE_CLOCK_NANOSLEEP)
19281928
if (clock_gettime(CLOCK_MONOTONIC, &nanosleep_time) == 0) {
@@ -2006,6 +2006,9 @@ iperf_send_mt(struct iperf_stream *sp)
20062006
register struct iperf_test *test = sp->test;
20072007
struct iperf_time now;
20082008
int throttle_check_per_message;
2009+
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
2010+
int throttle_check;
2011+
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */
20092012

20102013
/* Can we do multisend mode? */
20112014
if (test->settings->burst != 0)
@@ -2016,7 +2019,20 @@ iperf_send_mt(struct iperf_stream *sp)
20162019
multisend = 1; /* nope */
20172020

20182021
/* Should bitrate throttle be checked for every send */
2022+
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
2023+
if (test->settings->rate != 0) {
2024+
throttle_check = 1;
2025+
if (test->settings->burst == 0)
2026+
throttle_check_per_message = 1;
2027+
else
2028+
throttle_check_per_message = 0;
2029+
} else {
2030+
throttle_check = 0;
2031+
throttle_check_per_message = 0;
2032+
}
2033+
#else /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
20192034
throttle_check_per_message = test->settings->rate != 0 && test->settings->burst == 0;
2035+
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */
20202036

20212037
for (message_sent = 0; sp->green_light && multisend > 0; --multisend) {
20222038
// XXX If we hit one of these ending conditions maybe
@@ -2042,7 +2058,8 @@ iperf_send_mt(struct iperf_stream *sp)
20422058
message_sent = 1;
20432059
}
20442060
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
2045-
if (!sp->green_light) { /* Should check if green ligh can be set, as pacing timer is not supported in this case */
2061+
/* Should check if green light can be set, as pacing timer is not supported in this case */
2062+
if (throttle_check && !throttle_check_per_message) {
20462063
#else /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
20472064
if (!throttle_check_per_message || message_sent == 0) { /* Throttle check if was not checked for each send */
20482065
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */

0 commit comments

Comments
 (0)