On 06/16/12 01:07, Christiano F. Haesbaert wrote:
Hi, this behaviour is really annoying, in tcp server, when the last
user disconnects, we don't update the status line, so it keeps showing
1 connected user, it would be better to show Conn: 0.
BEFORE
sauron:haesbaert: tcpbench -s
elapsed_ms bytes mbps bwidth
1000 645674612 5165.397 100.00%
Conn: 1 Mbps: 5165.397 Peak Mbps: 5165.397 Avg Mbps: 5165.397
2000 673254000 5386.032 100.00%
Conn: 1 Mbps: 5386.032 Peak Mbps: 5386.032 Avg Mbps: 5386.032
AFTER
gimli:obj: ./tcpbench -s
elapsed_ms bytes mbps bwidth
1000 314833908 2518.671 100.00%
Conn: 1 Mbps: 2518.671 Peak Mbps: 2518.671 Avg Mbps: 2518.671
Conn: 0 Mbps: 0.000 Peak Mbps: 2518.671 Avg Mbps: 0.000
NAN might be more appropriate than 0.
Also, only start timer if this is the first connection, this prevents
the display from not running while we have clients connecting (since
it always pushes the display 1 second in the future).
Are you sure about this? Looking at the code, I didn't get that
impression (not that I claim to know much about event(3)), but adding a
new connection every 0.5 seconds did not stop the output either.
You might also want sth like this, for completeness:
@@ -1208,6 +1210,7 @@ main(int argc, char **argv)
} else {
print_tcp_header();
evtimer_set(&mainstats.timer, tcp_process_slice, NULL);
+ tcp_process_slice(0, 0, NULL);
}
if (ptb->sflag)
/Alexander
Index: tcpbench.c
===================================================================
RCS file: /cvs/src/usr.bin/tcpbench/tcpbench.c,v
retrieving revision 1.35
diff -d -u -p -r1.35 tcpbench.c
--- tcpbench.c 8 May 2012 01:39:58 -0000 1.35
+++ tcpbench.c 15 Jun 2012 23:04:23 -0000
@@ -568,7 +568,7 @@ tcp_process_slice(int fd, short event, v
mainstats.peak_mbps = slice_mbps;
printf("Conn: %3d Mbps: %12.3Lf Peak Mbps: %12.3Lf Avg Mbps: %12.3Lf\n",
mainstats.nconns, slice_mbps, mainstats.peak_mbps,
- slice_mbps / mainstats.nconns);
+ mainstats.nconns ? slice_mbps / mainstats.nconns : 0);
mainstats.slice_bytes = 0;
set_slice_timer(mainstats.nconns> 0);
@@ -657,7 +657,6 @@ tcp_server_handle_sc(int fd, short event
free(sc);
mainstats.nconns--;
- set_slice_timer(mainstats.nconns> 0);
return;
}
if (ptb->vflag>= 3)
@@ -723,7 +722,8 @@ tcp_server_accept(int fd, short event, v
event_add(&sc->ev, NULL);
TAILQ_INSERT_TAIL(&sc_queue, sc, entry);
mainstats.nconns++;
- set_slice_timer(mainstats.nconns> 0);
+ if (mainstats.nconns == 1)
+ set_slice_timer(1);
if (ptb->vflag)
fprintf(stderr, "Accepted connection from %s, fd = %d\n",
tmp, sc->fd);
@@ -934,7 +934,8 @@ client_init(struct addrinfo *aitop, int
event_add(&sc->ev, NULL);
TAILQ_INSERT_TAIL(&sc_queue, sc, entry);
mainstats.nconns++;
- set_slice_timer(mainstats.nconns> 0);
+ if (mainstats.nconns == 1)
+ set_slice_timer(1);
}
freeaddrinfo(aitop);
if (aib != NULL)