Skip to content

Commit e5364f9

Browse files
committed
Rebase changes to get formal version of the state change debug messages
1 parent d5713db commit e5364f9

File tree

6 files changed

+78
-33
lines changed

6 files changed

+78
-33
lines changed

src/iperf_api.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,9 +1706,6 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
17061706
} else if (test->role == 'c' && (test->server_skew_threshold != 0)){
17071707
i_errno = IESERVERONLY;
17081708
return -1;
1709-
} else if (test->role == 'c' && rcv_timeout_flag && test->mode == SENDER){
1710-
i_errno = IERVRSONLYRCVTIMEOUT;
1711-
return -1;
17121709
} else if (test->role == 's' && (server_rsa_private_key || test->server_authorized_users) &&
17131710
!(server_rsa_private_key && test->server_authorized_users)) {
17141711
i_errno = IESETSERVERAUTH;
@@ -2142,6 +2139,40 @@ iperf_create_send_timers(struct iperf_test * test)
21422139
return 0;
21432140
}
21442141

2142+
/* cancel send (pacing) timers */
2143+
void
2144+
iperf_cancel_send_timers(struct iperf_test * test)
2145+
{
2146+
struct iperf_stream *sp;
2147+
2148+
SLIST_FOREACH(sp, &test->streams, streams) {
2149+
if (sp->send_timer != NULL) {
2150+
tmr_cancel(sp->send_timer);
2151+
sp->send_timer = NULL;
2152+
}
2153+
}
2154+
}
2155+
2156+
/* cancel all periodic timers */
2157+
void
2158+
iperf_cancel_periodic_timers(struct iperf_test * test)
2159+
{
2160+
if (test->debug_level >= DEBUG_LEVEL_INFO) {
2161+
iperf_printf(test, "Canceling all periodic timers\n");
2162+
}
2163+
2164+
iperf_cancel_send_timers(test);
2165+
2166+
if (test->stats_timer != NULL) {
2167+
tmr_cancel(test->stats_timer);
2168+
test->stats_timer = NULL;
2169+
}
2170+
if (test->reporter_timer != NULL) {
2171+
tmr_cancel(test->reporter_timer);
2172+
test->reporter_timer = NULL;
2173+
}
2174+
}
2175+
21452176
#if defined(HAVE_SSL)
21462177
int test_is_authorized(struct iperf_test *test){
21472178
if ( !(test->server_rsa_private_key && test->server_authorized_users)) {

src/iperf_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ void warning(const char *);
333333
int iperf_exchange_results(struct iperf_test *);
334334
int iperf_init_test(struct iperf_test *);
335335
int iperf_create_send_timers(struct iperf_test *);
336+
void iperf_cancel_periodic_timers(struct iperf_test *);
336337
int iperf_parse_arguments(struct iperf_test *, int, char **);
337338
int iperf_open_logfile(struct iperf_test *);
338339
void iperf_close_logfile(struct iperf_test *);
@@ -416,7 +417,6 @@ enum {
416417
IESKEWTHRESHOLD = 29, // Invalid value specified as skew threshold
417418
IEIDLETIMEOUT = 30, // Invalid value specified as idle state timeout
418419
IERCVTIMEOUT = 31, // Illegal message receive timeout
419-
IERVRSONLYRCVTIMEOUT = 32, // Client receive timeout is valid only in reverse mode
420420
IESNDTIMEOUT = 33, // Illegal message send timeout
421421
IEUDPFILETRANSFER = 34, // Cannot transfer file using UDP
422422
IESERVERAUTHUSERS = 35, // Cannot access authorized users file

src/iperf_client_api.c

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ iperf_handle_message_client(struct iperf_test *test)
358358
case TEST_RUNNING:
359359
break;
360360
case EXCHANGE_RESULTS:
361+
iperf_cancel_periodic_timers(test);
361362
if (iperf_exchange_results(test) < 0)
362363
return -1;
363364
break;
@@ -607,7 +608,7 @@ iperf_run_client(struct iperf_test * test)
607608

608609
/* Begin calculating CPU utilization */
609610
cpu_util(NULL);
610-
if (test->mode != SENDER)
611+
if (test->mode != SENDER || test->state != TEST_RUNNING)
611612
rcv_timeout_us = (test->settings->rcv_timeout.secs * SEC_TO_US) + test->settings->rcv_timeout.usecs;
612613
else
613614
rcv_timeout_us = 0;
@@ -622,16 +623,16 @@ iperf_run_client(struct iperf_test * test)
622623
iperf_time_now(&now);
623624
timeout = tmr_timeout(&now);
624625

625-
// In reverse active mode client ensures data is received
626-
if (test->state == TEST_RUNNING && rcv_timeout_us > 0) {
626+
// In non-sending active mode or not during active test, client ensures data םor control messages are received
627+
if (rcv_timeout_us > 0) {
627628
timeout_us = -1;
628629
if (timeout != NULL) {
629630
used_timeout.tv_sec = timeout->tv_sec;
630631
used_timeout.tv_usec = timeout->tv_usec;
631632
timeout_us = (timeout->tv_sec * SEC_TO_US) + timeout->tv_usec;
632633
}
633-
/* Cap the maximum select timeout at 1 second */
634-
if (timeout_us > SEC_TO_US) {
634+
/* Cap the maximum select timeout at 1 second during active test*/
635+
if (test->state == TEST_RUNNING && timeout_us > SEC_TO_US) {
635636
timeout_us = SEC_TO_US;
636637
}
637638
if (timeout_us < 0 || timeout_us > rcv_timeout_us) {
@@ -641,6 +642,8 @@ iperf_run_client(struct iperf_test * test)
641642
timeout = &used_timeout;
642643
}
643644

645+
if (timeout) timeout_us = (timeout->tv_sec * SEC_TO_US) + timeout->tv_usec;
646+
644647
#if (defined(__vxworks)) || (defined(__VXWORKS__))
645648
if (timeout != NULL && timeout->tv_sec == 0 && timeout->tv_usec == 0) {
646649
taskDelay (1);
@@ -657,23 +660,32 @@ iperf_run_client(struct iperf_test * test)
657660
if (result < 0 && errno != EINTR) {
658661
i_errno = IESELECT;
659662
goto cleanup_and_fail;
660-
} else if (result == 0 && test->state == TEST_RUNNING && rcv_timeout_us > 0) {
663+
} else if (result == 0 && rcv_timeout_us > 0) {
661664
/*
662-
* If nothing was received in non-reverse running state
663-
* then probably something got stuck - either client,
664-
* server or network, and test should be terminated./
665+
* If nothing was received then probably something got stuck -
666+
* either client, server or network, and test should be terminated.
665667
*/
666668
iperf_time_now(&now);
667-
if (iperf_time_diff(&now, &last_receive_time, &diff_time) == 0) {
668-
t_usecs = iperf_time_in_usecs(&diff_time);
669-
if (t_usecs > rcv_timeout_us) {
670-
/* Idle timeout if no new blocks received */
671-
if (test->blocks_received == last_receive_blocks) {
672-
i_errno = IENOMSG;
673-
goto cleanup_and_fail;
669+
if (test->state == TEST_RUNNING && test->mode != SENDER) { // Check if data is received
670+
if (iperf_time_diff(&now, &last_receive_time, &diff_time) == 0) {
671+
t_usecs = iperf_time_in_usecs(&diff_time);
672+
if (t_usecs > rcv_timeout_us) {
673+
/* Idle timeout if no new blocks received */
674+
if (test->blocks_received == last_receive_blocks) {
675+
if (test->debug_level >= DEBUG_LEVEL_INFO) {
676+
iperf_printf(test, "Receiving data blocks timed out\n");
677+
}
678+
i_errno = IENOMSG;
679+
goto cleanup_and_fail;
680+
}
674681
}
675682
}
676-
683+
} else if (test->state != TEST_RUNNING && rcv_timeout_us == timeout_us) { // Check if control messages are received
684+
if (test->debug >= DEBUG_LEVEL_INFO) {
685+
iperf_printf(test, "Receiving control messages timed out\n");
686+
}
687+
i_errno = IENOMSG;
688+
goto cleanup_and_fail;
677689
}
678690
}
679691

src/iperf_error.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ iperf_strerror(int int_errno)
377377
case IEUDPFILETRANSFER:
378378
snprintf(errstr, len, "cannot transfer file using UDP");
379379
break;
380-
case IERVRSONLYRCVTIMEOUT:
381-
snprintf(errstr, len, "client receive timeout is valid only in receiving mode");
382-
perr = 1;
383-
break;
384380
case IEDAEMON:
385381
snprintf(errstr, len, "unable to become a daemon");
386382
perr = 1;
@@ -480,7 +476,7 @@ iperf_strerror(int int_errno)
480476
snprintf(errstr, len, "host device name (ip%%<dev>) is supported (and required) only for IPv6 link-local address");
481477
break;
482478
case IENOMSG:
483-
snprintf(errstr, len, "idle timeout for receiving data");
479+
snprintf(errstr, len, "idle timeout for receiving data or control messages");
484480
break;
485481
case IESETDONTFRAGMENT:
486482
snprintf(errstr, len, "unable to set IP Do-Not-Fragment flag");

src/iperf_locale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const char usage_longstr[] = "Usage: iperf3 [-s|-c host] [options]\n"
123123
" --timestamps<=format> emit a timestamp at the start of each output line\n"
124124
" (optional \"=\" and format string as per strftime(3))\n"
125125

126-
" --rcv-timeout # idle timeout for receiving data (default %d ms)\n"
126+
" --rcv-timeout # idle timeout for receiving data or control messages (default %d ms)\n"
127127
#if defined(HAVE_TCP_USER_TIMEOUT)
128128
" --snd-timeout # timeout for unacknowledged TCP data\n"
129129
" (in ms, default is system settings)\n"

src/iperf_server_api.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ iperf_handle_message_server(struct iperf_test *test)
272272
test->reporter_callback(test);
273273
if (iperf_set_send_state(test, EXCHANGE_RESULTS) != 0)
274274
return -1;
275+
276+
iperf_cancel_periodic_timers(test);
277+
275278
if (iperf_exchange_results(test) < 0)
276279
return -1;
277280
if (iperf_set_send_state(test, DISPLAY_RESULTS) != 0)
@@ -605,15 +608,16 @@ iperf_run_server(struct iperf_test *test)
605608
used_timeout.tv_usec = 0;
606609
timeout = &used_timeout;
607610
}
608-
} else if (test->mode != SENDER) { // In non-reverse active mode server ensures data is received
611+
} else if (test->mode != SENDER || test->state != TEST_RUNNING) {
612+
// In non-reverse active mode or not during active test, server ensures data םor control messages are received
609613
timeout_us = -1;
610614
if (timeout != NULL) {
611615
used_timeout.tv_sec = timeout->tv_sec;
612616
used_timeout.tv_usec = timeout->tv_usec;
613617
timeout_us = (timeout->tv_sec * SEC_TO_US) + timeout->tv_usec;
614618
}
615-
/* Cap the maximum select timeout at 1 second */
616-
if (timeout_us > SEC_TO_US) {
619+
/* Cap the maximum select timeout at 1 second during active test */
620+
if (test->state == TEST_RUNNING && timeout_us > SEC_TO_US) {
617621
timeout_us = SEC_TO_US;
618622
}
619623
if (timeout_us < 0 || timeout_us > rcv_timeout_us) {
@@ -660,10 +664,12 @@ iperf_run_server(struct iperf_test *test)
660664
}
661665

662666
/*
663-
* Running a test. If we're receiving, be sure we're making
664-
* progress (sender hasn't died/crashed).
667+
* Receiver when running a test or after test ended.
668+
* Be sure we're making progress (sender hasn't died/crashed).
665669
*/
666-
else if (test->mode != SENDER && t_usecs > rcv_timeout_us) {
670+
else if ( t_usecs > rcv_timeout_us &&
671+
(test->mode != SENDER || test->state != TEST_RUNNING) )
672+
{
667673
/* Idle timeout if no new blocks received */
668674
if (test->blocks_received == last_receive_blocks) {
669675
test->server_forced_no_msg_restarts_count += 1;

0 commit comments

Comments
 (0)