diff --git a/src/iperf_api.c b/src/iperf_api.c index 2c3dccb..30b7693 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1002,7 +1002,7 @@ iperf_check_throttle(struct iperf_stream *sp, struct timeval *nowP) int 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; struct timeval now; @@ -1017,6 +1017,7 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) for (; multisend > 0; --multisend) { if (test->settings->rate != 0 && test->settings->burst == 0) gettimeofday(&now, NULL); + streams_active = 0; SLIST_FOREACH(sp, &test->streams, streams) { if (sp->green_light && (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; return r; } + streams_active = 1; test->bytes_sent += r; ++test->blocks_sent; if (test->settings->rate != 0 && test->settings->burst == 0) @@ -1036,6 +1038,8 @@ iperf_send(struct iperf_test *test, fd_set *write_setP) break; } } + if (!streams_active) + break; } if (test->settings->burst != 0) { gettimeofday(&now, NULL); diff --git a/src/net.c b/src/net.c index cc5a7c1..3009dc3 100644 --- a/src/net.c +++ b/src/net.c @@ -324,6 +324,8 @@ Nsendfile(int fromfd, int tofd, const char *buf, size_t count) switch (errno) { case EINTR: case EAGAIN: + if (count == nleft) + return NET_SOFTERROR; return count - nleft; case ENOBUFS: