Skip to content

Commit

Permalink
Changes per reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Aug 29, 2024
1 parent 783095e commit af81adc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1639,12 +1639,10 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
test->use_pkcs1_padding = 1;
break;
#endif /* HAVE_SSL */
#if !defined(HAVE_CLOCK_NANOSLEEP) && !defined(HAVE_NANOSLEEP)
case OPT_PACING_TIMER:
test->settings->pacing_timer = unit_atoi(optarg);
client_flag = 1;
break;
#endif /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
case OPT_CONNECT_TIMEOUT:
test->settings->connect_timeout = unit_atoi(optarg);
client_flag = 1;
Expand Down Expand Up @@ -1888,7 +1886,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)

#if defined(HAVE_CLOCK_NANOSLEEP) || defined(HAVE_NANOSLEEP)
struct timespec nanosleep_time;
int64_t time_to_green_ligh, delta_bits;
int64_t time_to_green_light, delta_bits;
int ret;
#endif /* HAVE_CLOCK_NANOSLEEP || HAVE_NANOSLEEP) */
#if defined(HAVE_CLOCK_NANOSLEEP)
Expand All @@ -1914,13 +1912,13 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)
if (missing_rate < 0) {
delta_bits = bits_sent - (seconds * sp->test->settings->rate);
// Calclate time until next data send is required
time_to_green_ligh = (SEC_TO_NS * delta_bits / sp->test->settings->rate);
time_to_green_light = (SEC_TO_NS * delta_bits / sp->test->settings->rate);
// Whether shouuld wait before next send
if (time_to_green_ligh >= 0) {
if (time_to_green_light >= 0) {
#if defined(HAVE_CLOCK_NANOSLEEP)
if (clock_gettime(CLOCK_MONOTONIC, &nanosleep_time) == 0) {
// Calculate absolute end of sleep time
ns = nanosleep_time.tv_nsec + time_to_green_ligh;
ns = nanosleep_time.tv_nsec + time_to_green_light;
if (ns < SEC_TO_NS) {
nanosleep_time.tv_nsec = ns;
} else {
Expand All @@ -1939,10 +1937,10 @@ iperf_check_throttle(struct iperf_stream *sp, struct iperf_time *nowP)
// Sleep until average baud rate reaches the target value or intrupt / error
do {
// nansleep() time should be less than 1 sec
nanosleep_time.tv_nsec = (time_to_green_ligh >= SEC_TO_NS) ? SEC_TO_NS - 1 : time_to_green_ligh;
time_to_green_ligh -= nanosleep_time.tv_nsec;
nanosleep_time.tv_nsec = (time_to_green_light >= SEC_TO_NS) ? SEC_TO_NS - 1 : time_to_green_light;
time_to_green_light -= nanosleep_time.tv_nsec;
ret = nanosleep(&nanosleep_time, NULL);
} while (ret == 0 && time_to_green_ligh > 0);
} while (ret == 0 && time_to_green_light > 0);
if (ret == 0) {
sp->green_light = 1;
}
Expand Down
3 changes: 3 additions & 0 deletions src/iperf_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
" (optional slash and packet count for burst mode)\n"
#if !defined(HAVE_CLOCK_NANOSLEEP) && !defined(HAVE_NANOSLEEP)
" --pacing-timer #[KMG] set the timing for pacing, in microseconds (default %d)\n"
#else
" --pacing-timer #[KMG] set the Server timing for pacing, in microseconds (default %d)\n"
" (used by the server only if this option is in its help message)\n"
#endif /* !HAVE_CLOCK_NANOSLEEP && !HAVE_NANOSLEEP */
#if defined(HAVE_SO_MAX_PACING_RATE)
" --fq-rate #[KMG] enable fair-queuing based socket pacing in\n"
Expand Down

0 comments on commit af81adc

Please sign in to comment.