gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3344 - GNUnet/src/util/os


From: grothoff
Subject: [GNUnet-SVN] r3344 - GNUnet/src/util/os
Date: Tue, 29 Aug 2006 10:41:32 -0700 (PDT)

Author: grothoff
Date: 2006-08-29 10:41:31 -0700 (Tue, 29 Aug 2006)
New Revision: 3344

Modified:
   GNUnet/src/util/os/cpustatus.c
Log:
fix

Modified: GNUnet/src/util/os/cpustatus.c
===================================================================
--- GNUnet/src/util/os/cpustatus.c      2006-08-29 17:03:37 UTC (rev 3343)
+++ GNUnet/src/util/os/cpustatus.c      2006-08-29 17:41:31 UTC (rev 3344)
@@ -373,8 +373,8 @@
                                              "LOAD",
                                              "MAXCPULOAD",
                                              0,
+                                             10000, /* more than 1 CPU 
possible */
                                              100,
-                                             100,
                                              &maxCPULoad))
     return -1;
   MUTEX_LOCK(statusMutex);
@@ -390,6 +390,12 @@
     return ret;
   }
   currentLoad = updateCpuUsage();
+  if (currentLoad == -1) {
+    lastRet = -1;
+    MUTEX_UNLOCK(statusMutex);
+    return -1;
+  }
+    
   ret = (100 * currentLoad) / maxCPULoad;
   /* for CPU, we don't do the 'fast increase' since CPU is much
      more jitterish to begin with */
@@ -409,13 +415,14 @@
 void __attribute__ ((constructor)) gnunet_cpustats_ltdl_init() {
   statusMutex = MUTEX_CREATE(NO);
 #ifdef LINUX
-  proc_stat = fopen("/proc/stat", "r");
+  proc_stat = fopen("/proc/stat", "r");  
   if (NULL == proc_stat)
     GE_LOG_STRERROR_FILE(NULL,
                         GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
                         "fopen",
                         "/proc/stat");
 #endif
+  updateCpuUsage(); /* initialize */
 }
 
 /**





reply via email to

[Prev in Thread] Current Thread [Next in Thread]