clear conky vars on disconnect/failure to open files
authorPhilip Kovacs <pkovacs@users.sourceforge.net>
Tue, 26 Dec 2006 20:49:35 +0000 (20:49 +0000)
committerPhilip Kovacs <pkovacs@users.sourceforge.net>
Tue, 26 Dec 2006 20:49:35 +0000 (20:49 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@820 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
src/linux.c

index fa53480..2a057c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 # $Id$
 
+2006-12-26
+       * Clear conky vars on disconnect/failure to open files.
+
 2006-12-23
        * Updated to libmpdclient 0.12.0
 
index 446e4e4..228011b 100644 (file)
@@ -75,6 +75,7 @@ void update_uptime()
   
     if (!(fp = open_file("/proc/uptime", &rep)))
     {
+      info.uptime=0.0;
       return;
     }
          fscanf(fp, "%lf", &info.uptime);
@@ -149,7 +150,10 @@ inline void update_net_stats()
 
        /* open file and ignore first two lines */
   if (!(net_dev_fp = open_file("/proc/net/dev", &rep)))
+  {
+    clear_net_stats ();
     return;
+  }
 
        fgets(buf, 255, net_dev_fp);    /* garbage */
        fgets(buf, 255, net_dev_fp);    /* garbage (field names) */
@@ -326,6 +330,7 @@ void update_total_processes()
 
     if (!(fp = open_file("/proc/loadavg", &rep)))
     {
+      info.procs=0;
       return;
     }
     fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs );
@@ -428,7 +433,14 @@ inline static void update_stat()
        }
 
   if (!(stat_fp = open_file("/proc/stat", &rep)))
+  {
+    info.run_procs=0;
+    if (info.cpu_usage)
+    {
+       memset(info.cpu_usage, 0, info.cpu_count * sizeof (float));
+    }
     return;
+  }
 
        index = 0;
        while (!feof(stat_fp)) {
@@ -1519,7 +1531,10 @@ void update_diskio()
        int col_count = 0;
 
        if (!(fp =open_file("/proc/diskstats", &rep)))
+  {
+      diskio_value=0;
       return;
+  }
 
        /* read reads and writes from all disks (minor = 0), including
         * cd-roms and floppies, and summ them up