-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Resolve server/client stuck at the test end before results-exchange #1527
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,7 +124,6 @@ iperf_server_listen(struct iperf_test *test) | |
} | ||
|
||
FD_ZERO(&test->read_set); | ||
FD_ZERO(&test->write_set); | ||
FD_SET(test->listener, &test->read_set); | ||
if (test->listener > test->max_fd) test->max_fd = test->listener; | ||
|
||
|
@@ -236,7 +235,6 @@ iperf_handle_message_server(struct iperf_test *test) | |
test->stats_callback(test); | ||
SLIST_FOREACH(sp, &test->streams, streams) { | ||
FD_CLR(sp->socket, &test->read_set); | ||
FD_CLR(sp->socket, &test->write_set); | ||
close(sp->socket); | ||
} | ||
test->reporter_callback(test); | ||
|
@@ -266,8 +264,8 @@ iperf_handle_message_server(struct iperf_test *test) | |
iperf_err(test, "the client has terminated"); | ||
SLIST_FOREACH(sp, &test->streams, streams) { | ||
FD_CLR(sp->socket, &test->read_set); | ||
FD_CLR(sp->socket, &test->write_set); | ||
close(sp->socket); | ||
sp->socket = -1; | ||
} | ||
test->state = IPERF_DONE; | ||
break; | ||
|
@@ -294,6 +292,7 @@ server_timer_proc(TimerClientData client_data, struct iperf_time *nowP) | |
sp = SLIST_FIRST(&test->streams); | ||
SLIST_REMOVE_HEAD(&test->streams, streams); | ||
close(sp->socket); | ||
sp->socket = -1; | ||
iperf_free_stream(sp); | ||
} | ||
close(test->ctrl_sck); | ||
|
@@ -444,7 +443,6 @@ cleanup_server(struct iperf_test *test) | |
SLIST_FOREACH(sp, &test->streams, streams) { | ||
if (sp->socket > -1) { | ||
FD_CLR(sp->socket, &test->read_set); | ||
FD_CLR(sp->socket, &test->write_set); | ||
close(sp->socket); | ||
sp->socket = -1; | ||
} | ||
|
@@ -463,28 +461,13 @@ cleanup_server(struct iperf_test *test) | |
close(test->prot_listener); | ||
test->prot_listener = -1; | ||
} | ||
|
||
/* Cancel any remaining timers. */ | ||
if (test->stats_timer != NULL) { | ||
tmr_cancel(test->stats_timer); | ||
test->stats_timer = NULL; | ||
} | ||
if (test->reporter_timer != NULL) { | ||
tmr_cancel(test->reporter_timer); | ||
test->reporter_timer = NULL; | ||
} | ||
if (test->omit_timer != NULL) { | ||
tmr_cancel(test->omit_timer); | ||
test->omit_timer = NULL; | ||
} | ||
|
||
iperf_cancel_test_timers(test); /* Cancel any remaining timers. */ | ||
|
||
if (test->congestion_used != NULL) { | ||
free(test->congestion_used); | ||
test->congestion_used = NULL; | ||
} | ||
if (test->timer != NULL) { | ||
tmr_cancel(test->timer); | ||
test->timer = NULL; | ||
} | ||
} | ||
|
||
|
||
|
@@ -497,7 +480,7 @@ iperf_run_server(struct iperf_test *test) | |
#if defined(HAVE_TCP_CONGESTION) | ||
int saved_errno; | ||
#endif /* HAVE_TCP_CONGESTION */ | ||
fd_set read_set, write_set; | ||
fd_set read_set; | ||
struct iperf_stream *sp; | ||
struct iperf_time now; | ||
struct iperf_time last_receive_time; | ||
|
@@ -560,7 +543,6 @@ iperf_run_server(struct iperf_test *test) | |
} | ||
|
||
memcpy(&read_set, &test->read_set, sizeof(fd_set)); | ||
memcpy(&write_set, &test->write_set, sizeof(fd_set)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this means that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the comment. Forgot to remove all occurances of |
||
|
||
iperf_time_now(&now); | ||
timeout = tmr_timeout(&now); | ||
|
@@ -572,7 +554,11 @@ iperf_run_server(struct iperf_test *test) | |
used_timeout.tv_usec = 0; | ||
timeout = &used_timeout; | ||
} | ||
} else if (test->mode != SENDER) { // In non-reverse active mode server ensures data is received | ||
} else if (test->mode != SENDER // In non-reverse active mode server ensures data is received. | ||
|| test->state == TEST_END // Same for receiving control messages at the end of the test. | ||
|| test->state == EXCHANGE_RESULTS | ||
|| test->state == DISPLAY_RESULTS) | ||
{ | ||
timeout_us = -1; | ||
if (timeout != NULL) { | ||
used_timeout.tv_sec = timeout->tv_sec; | ||
|
@@ -590,7 +576,7 @@ iperf_run_server(struct iperf_test *test) | |
timeout = &used_timeout; | ||
} | ||
|
||
result = select(test->max_fd + 1, &read_set, &write_set, NULL, timeout); | ||
result = select(test->max_fd + 1, &read_set, NULL, NULL, timeout); | ||
if (result < 0 && errno != EINTR) { | ||
cleanup_server(test); | ||
i_errno = IESELECT; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change creates a scenario with an early timeout.
Given:
test->mode == SENDER
rcv_timeout_value_in_us > 0
test->state == TEST_END
(orEXCHANGE_RESULTS
orDISPLAY_RESULTS
)This implies that
rcv_timeout_us = 0
. Then on line 642, the if statement will evaluate to something likeif (t_usecs > 0)
; always being true sincet_usecs
will pretty much always be greater than 0.It might make more sense to split the blocks so the correct timeout is used:
(I've also renamed
rcv_timeout_value_in_us
->end_rcv_timeout
andrcv_timeout_us
->running_rcv_timeout
to hopefully make their use more clear)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only
rcv_timeout_us
value is used for timeout (in theselect
statement). The value ofrcv_timeout_value_in_us
is only used to initializercv_timeout_us
and to indicate for for the ending states whether receive timeout was requested (as there is no "timeout requested" setting). Therefore, the current code is correct in that respect.I agree that probably
rcv_timeout_value_in_us
may have a better name, likercv_timeout_setting_us
but I won't make a change just for that.