[core] Fix connection bandwidth stats calculation

personal/stbuehler/wip
Thomas Porzelt 13 years ago
parent 38e438fb94
commit 6184f88e08
  1. 10
      src/main/connection.c

@ -231,6 +231,14 @@ static void connection_cb(struct ev_loop *loop, ev_io *w, int revents) {
con->wrk->stats.bytes_in += transferred;
con->stats.bytes_in += transferred;
if ((ev_now(loop) - con->stats.last_avg) >= 5.0) {
con->stats.bytes_out_5s_diff = con->stats.bytes_out - con->stats.bytes_out_5s;
con->stats.bytes_out_5s = con->stats.bytes_out;
con->stats.bytes_in_5s_diff = con->stats.bytes_in - con->stats.bytes_in_5s;
con->stats.bytes_in_5s = con->stats.bytes_in;
con->stats.last_avg = ev_now(loop);
}
switch (res) {
case LI_NETWORK_STATUS_SUCCESS:
if (!connection_handle_read(con)) return;
@ -295,7 +303,7 @@ static void connection_cb(struct ev_loop *loop, ev_io *w, int revents) {
}
if ((ev_now(loop) - con->stats.last_avg) >= 5.0) {
con->stats.bytes_out_5s_diff = con->wrk->stats.bytes_out - con->wrk->stats.bytes_out_5s;
con->stats.bytes_out_5s_diff = con->stats.bytes_out - con->stats.bytes_out_5s;
con->stats.bytes_out_5s = con->stats.bytes_out;
con->stats.bytes_in_5s_diff = con->stats.bytes_in - con->stats.bytes_in_5s;
con->stats.bytes_in_5s = con->stats.bytes_in;

Loading…
Cancel
Save