Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that bitrate is ignored when burst is set (with Nanosleep) #1821

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,7 +1913,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)
delta_bits = bits_sent - (seconds * sp->test->settings->rate);
// Calclate time until next data send is required
time_to_green_light = (SEC_TO_NS * delta_bits / sp->test->settings->rate);
// Whether shouuld wait before next send
// Whether should wait before next send
if (time_to_green_light >= 0) {
#if defined(HAVE_CLOCK_NANOSLEEP)
if (clock_gettime(CLOCK_MONOTONIC, &nanosleep_time) == 0) {
Expand Down Expand Up @@ -1997,6 +1997,9 @@ iperf_send_mt(struct iperf_stream *sp)
register struct iperf_test *test = sp->test;
struct iperf_time now;
int throttle_check_per_message;
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
int throttle_check;
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */

/* Can we do multisend mode? */
if (test->settings->burst != 0)
Expand All @@ -2007,7 +2010,20 @@ iperf_send_mt(struct iperf_stream *sp)
multisend = 1; /* nope */

/* Should bitrate throttle be checked for every send */
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
if (test->settings->rate != 0) {
throttle_check = 1;
if (test->settings->burst == 0)
throttle_check_per_message = 1;
else
throttle_check_per_message = 0;
} else {
throttle_check = 0;
throttle_check_per_message = 0;
}
#else /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
throttle_check_per_message = test->settings->rate != 0 && test->settings->burst == 0;
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */

for (message_sent = 0; sp->green_light && multisend > 0; --multisend) {
// XXX If we hit one of these ending conditions maybe
Expand All @@ -2033,7 +2049,8 @@ iperf_send_mt(struct iperf_stream *sp)
message_sent = 1;
}
#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
if (!sp->green_light) { /* Should check if green ligh can be set, as pacing timer is not supported in this case */
/* Should check if green light can be set, as pacing timer is not supported in this case */
if (throttle_check && !throttle_check_per_message) {
#else /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
if (!throttle_check_per_message || message_sent == 0) { /* Throttle check if was not checked for each send */
#endif /* HAVE_CLOCK_NANOSLEEP, HAVE_NANOSLEEP */
Expand Down
Loading