diff options
Diffstat (limited to 'src/iperf_tcp.c')
-rw-r--r-- | src/iperf_tcp.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index ce6a522..71c40a6 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -126,9 +126,26 @@ iperf_tcp_accept(struct iperf_test * test) i_errno = IESTREAMCONNECT; return -1; } +#if defined(HAVE_SO_MAX_PACING_RATE) + /* If fq socket pacing is specified, enable it. */ + + if (test->settings->fqrate) { + /* Convert bits per second to bytes per second */ + unsigned int fqrate = test->settings->fqrate / 8; + if (fqrate > 0) { + if (test->debug) { + printf("Setting fair-queue socket pacing to %u\n", fqrate); + } + if (setsockopt(s, SOL_SOCKET, SO_MAX_PACING_RATE, &fqrate, sizeof(fqrate)) < 0) { + warning("Unable to set socket pacing"); + } + } + } +#endif /* HAVE_SO_MAX_PACING_RATE */ if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) { i_errno = IERECVCOOKIE; + close(s); return -1; } @@ -240,21 +257,6 @@ iperf_tcp_listen(struct iperf_test *test) return -1; } } -#if defined(HAVE_SO_MAX_PACING_RATE) - /* If fq socket pacing is specified, enable it. */ - if (test->settings->fqrate) { - /* Convert bits per second to bytes per second */ - unsigned int fqrate = test->settings->fqrate / 8; - if (fqrate > 0) { - if (test->debug) { - printf("Setting fair-queue socket pacing to %u\n", fqrate); - } - if (setsockopt(s, SOL_SOCKET, SO_MAX_PACING_RATE, &fqrate, sizeof(fqrate)) < 0) { - warning("Unable to set socket pacing"); - } - } - } -#endif /* HAVE_SO_MAX_PACING_RATE */ { unsigned int rate = test->settings->rate / 8; if (rate > 0) { @@ -309,6 +311,7 @@ iperf_tcp_listen(struct iperf_test *test) if (listen(s, INT_MAX) < 0) { i_errno = IESTREAMLISTEN; + close(s); return -1; } @@ -329,6 +332,7 @@ iperf_tcp_listen(struct iperf_test *test) } if (test->settings->socket_bufsize && test->settings->socket_bufsize > sndbuf_actual) { i_errno = IESETBUF2; + close(s); return -1; } @@ -346,6 +350,7 @@ iperf_tcp_listen(struct iperf_test *test) } if (test->settings->socket_bufsize && test->settings->socket_bufsize > rcvbuf_actual) { i_errno = IESETBUF2; + close(s); return -1; } |