From 613df97a6c66c563deb571f9eaa3eca84a742553 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Mon, 16 Mar 2009 14:13:33 -0600 Subject: [PATCH] Fix wacky net speed values on startup. --- src/linux.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/linux.c b/src/linux.c index 32bedc8b..555d3419 100644 --- a/src/linux.c +++ b/src/linux.c @@ -319,6 +319,7 @@ void update_net_stats(void) { FILE *net_dev_fp; static int rep = 0; + static char first = 1; // FIXME: arbitrary size chosen to keep code simple. int i, i2; @@ -442,9 +443,12 @@ void update_net_stats(void) /*** end ip addr patch ***/ - /* calculate speeds */ - ns->net_rec[0] = (ns->recv - last_recv) / delta; - ns->net_trans[0] = (ns->trans - last_trans) / delta; + if (!first) { + /* calculate speeds */ + ns->net_rec[0] = (ns->recv - last_recv) / delta; + ns->net_trans[0] = (ns->trans - last_trans) / delta; + } + curtmp1 = 0; curtmp2 = 0; // get an average @@ -525,6 +529,7 @@ void update_net_stats(void) free(winfo); #endif } + first = 0; fclose(net_dev_fp);