|
From: <mla...@us...> - 2009-04-27 04:26:27
|
Revision: 502
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=502&view=rev
Author: mlampard
Date: 2009-04-27 04:26:18 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
g15stats: Detect bad network interface. Resolve issue causing 100% cpu usage.
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:26:18 UTC (rev 502)
@@ -5,3 +5,4 @@
SVN:
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
+- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:26:18 UTC (rev 502)
@@ -57,6 +57,7 @@
int g15screen_fd;
int cycle = 0;
+int have_nic=0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -617,10 +618,19 @@
glibtop_netload netload;
static unsigned long previous_in;
static unsigned long previous_out;
+ int mac=0;
+ glibtop_get_netload(&netload,interface);
+ for(i=0;i<8;i++)
+ mac+=netload.hwaddress[i];
+ if(!mac) {
+ printf("Interface %s does not appear to exist. Net screen will be disabled.\n",interface);
+ have_nic = 0;
+ return; // interface probably doesn't exist - no mac address
+ }
+
while(1) {
int j=0, max_in=0, max_out=0;
- glibtop_get_netload(&netload,interface);
if(previous_in+previous_out==0)
goto last;
@@ -644,11 +654,13 @@
}
net_rr_index=i;
i++; if(i>MAX_NET_HIST) i=0;
-
- sleep (1);
+
last:
previous_in = netload.bytes_in;
previous_out = netload.bytes_out;
+ sleep (1);
+ glibtop_get_netload(&netload,interface);
+
}
}
@@ -677,7 +689,6 @@
int i;
int go_daemon=0;
- int have_nic=0;
unsigned char interface[128];
int multicore = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|