Only set sockets to non-blocking mode on the sending side of the

transfer.

Note that the sender can either be the client or the server depending
on whether --reverse is used.

This fixes some problems with UDP transfers getting severely confused
and (wrongly) complaining about packets arriving out of order.

Related to issue #125.
This commit is contained in:
Bruce A. Mah 2014-04-23 15:01:27 -07:00
parent e7841b0f92
commit cbacc1d670
No known key found for this signature in database
GPG Key ID: 4984910A8CAAEE8A
2 changed files with 16 additions and 7 deletions

View File

@ -381,9 +381,12 @@ iperf_run_client(struct iperf_test * test)
if (startup) {
startup = 0;
SLIST_FOREACH(sp, &test->streams, streams) {
setnonblocking(sp->socket, 1);
}
// If the client is sending (normal mode) then set nonblocking sockets
if (!test->reverse) {
SLIST_FOREACH(sp, &test->streams, streams) {
setnonblocking(sp->socket, 1);
}
}
}
if (test->reverse) {
@ -406,9 +409,12 @@ iperf_run_client(struct iperf_test * test)
(test->settings->bytes != 0 && test->bytes_sent >= test->settings->bytes) ||
(test->settings->blocks != 0 && test->blocks_sent >= test->settings->blocks))) {
SLIST_FOREACH(sp, &test->streams, streams) {
setnonblocking(sp->socket, 0);
}
// If the client is sending (normal mode) then undo nonblocking sockets
if (!test->reverse) {
SLIST_FOREACH(sp, &test->streams, streams) {
setnonblocking(sp->socket, 0);
}
}
/* Yes, done! Send TEST_END. */
test->done = 1;

View File

@ -516,7 +516,10 @@ iperf_run_server(struct iperf_test *test)
FD_SET(s, &test->read_set);
if (s > test->max_fd) test->max_fd = s;
setnonblocking(s, 1);
// If the server is sending (reverse mode) then set nonblocking sockets
if (test->reverse) {
setnonblocking(s, 1);
}
streams_accepted++;
if (test->on_new_stream)