From: henning Date: Thu, 14 Aug 2008 22:29:43 +0000 (+0000) Subject: only update stats when we actually wrote sth, relevant for -n, ok djm X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=00a1581232238e5ab6564765fa5436d0de1f2319;p=openbsd only update stats when we actually wrote sth, relevant for -n, ok djm From: Pierre Riteau --- diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c index 10709ef1d14..bfb444035e3 100644 --- a/usr.bin/tcpbench/tcpbench.c +++ b/usr.bin/tcpbench/tcpbench.c @@ -700,20 +700,22 @@ clientloop(kvm_t *kvmh, u_long ktcbtab, const char *host, const char *port, err(1, "poll"); } for (i = 0; i < nconn; i++) { - if (pfd[i].revents & POLLOUT) + if (pfd[i].revents & POLLOUT) { if ((n = write(pfd[i].fd, buf, Bflag)) == -1) { if (errno == EINTR || errno == EAGAIN) continue; err(1, "write"); } - if (n == 0) { - warnx("Remote end closed connection"); - done = -1; - break; + if (n == 0) { + warnx("Remote end closed connection"); + done = -1; + break; + } + if (vflag >= 3) + fprintf(stderr, "write: %zd bytes\n", + n); + stats_update(&sc, n); } - if (vflag >= 3) - fprintf(stderr, "write: %zd bytes\n", n); - stats_update(&sc, n); } } stats_finish(&sc); @@ -795,8 +797,7 @@ main(int argc, char **argv) errstr, optarg); break; case 'v': - if (vflag < 2) - vflag++; + vflag++; break; case 'n': nconn = strtonum(optarg, 0, 65535, &errstr);