summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2008-08-14 22:29:44 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2008-08-14 22:29:44 +0000
commit2eda1337ba22cdf0842d21329706bd7e24a410b4 (patch)
treee7fb17c9a057bad43474f1f71eac18a635fc652f /usr.bin
parent0e3d0e8375a630b155012ac0b49ae4bd7e0156f1 (diff)
only update stats when we actually wrote sth, relevant for -n, ok djm
From: Pierre Riteau <pierre.riteau@gmail.com>
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tcpbench/tcpbench.c21
1 files changed, 11 insertions, 10 deletions
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);