Drop out of multisend loop if none of the streams are accepting data

This commit is contained in:
Brian Candler 2014-12-23 09:38:50 +00:00
parent dba611dbe4
commit a80368bb7f
2 changed files with 7 additions and 1 deletions

View File

@ -1002,7 +1002,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct timeval *nowP)
int int
iperf_send(struct iperf_test *test, fd_set *write_setP) iperf_send(struct iperf_test *test, fd_set *write_setP)
{ {
register int multisend, r; register int multisend, r, streams_active;
register struct iperf_stream *sp; register struct iperf_stream *sp;
struct timeval now; struct timeval now;
@ -1017,6 +1017,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
for (; multisend > 0; --multisend) { for (; multisend > 0; --multisend) {
if (test->settings->rate != 0 && test->settings->burst == 0) if (test->settings->rate != 0 && test->settings->burst == 0)
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
streams_active = 0;
SLIST_FOREACH(sp, &test->streams, streams) { SLIST_FOREACH(sp, &test->streams, streams) {
if (sp->green_light && if (sp->green_light &&
(write_setP == NULL || FD_ISSET(sp->socket, write_setP))) { (write_setP == NULL || FD_ISSET(sp->socket, write_setP))) {
@ -1026,6 +1027,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
i_errno = IESTREAMWRITE; i_errno = IESTREAMWRITE;
return r; return r;
} }
streams_active = 1;
test->bytes_sent += r; test->bytes_sent += r;
++test->blocks_sent; ++test->blocks_sent;
if (test->settings->rate != 0 && test->settings->burst == 0) if (test->settings->rate != 0 && test->settings->burst == 0)
@ -1036,6 +1038,8 @@ iperf_send(struct iperf_test *test, fd_set *write_setP)
break; break;
} }
} }
if (!streams_active)
break;
} }
if (test->settings->burst != 0) { if (test->settings->burst != 0) {
gettimeofday(&now, NULL); gettimeofday(&now, NULL);

View File

@ -324,6 +324,8 @@ Nsendfile(int fromfd, int tofd, const char *buf, size_t count)
switch (errno) { switch (errno) {
case EINTR: case EINTR:
case EAGAIN: case EAGAIN:
if (count == nleft)
return NET_SOFTERROR;
return count - nleft; return count - nleft;
case ENOBUFS: case ENOBUFS: