gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1383 - GNUnet/src/util


From: grothoff
Subject: [GNUnet-SVN] r1383 - GNUnet/src/util
Date: Sun, 10 Jul 2005 17:05:20 -0700 (PDT)

Author: grothoff
Date: 2005-07-10 17:05:17 -0700 (Sun, 10 Jul 2005)
New Revision: 1383

Modified:
   GNUnet/src/util/statuscalls.c
Log:
DBZ

Modified: GNUnet/src/util/statuscalls.c
===================================================================
--- GNUnet/src/util/statuscalls.c       2005-07-10 23:43:31 UTC (rev 1382)
+++ GNUnet/src/util/statuscalls.c       2005-07-11 00:05:17 UTC (rev 1383)
@@ -658,10 +658,12 @@
   static unsigned long long overload;
   static unsigned long long lastSum;
   static cron_t lastCall;
+  static int lastValue;
   cron_t now;
   unsigned long long maxExpect;
   unsigned long long currentLoadSum;
   int i;
+  int ret;
 
   MUTEX_LOCK(&statusMutex);
   currentLoadSum = globalTrafficBetweenProc.last_out;
@@ -679,6 +681,18 @@
     MUTEX_UNLOCK(&statusMutex);
     return -1;
   }
+  if (maxNetDownBPS == 0) {
+    MUTEX_UNLOCK(&statusMutex);
+    return -1;
+  }
+  if (lastCall - now < cronSECONDS) {
+    /* increase last load proportional to difference in
+       data transmitted and in relation to the limit */
+    ret = lastValue + 100 * (currentLoadSum - lastSum) / maxNetDownBPS;
+    MUTEX_UNLOCK(&statusMutex);
+    return ret;
+  }
+     
   currentLoadSum += overload;
   maxExpect = ( (lastCall - now) * maxNetDownBPS ) / cronSECONDS;
   lastCall = now;
@@ -686,8 +700,10 @@
     overload = 0;
   else 
     overload = currentLoadSum - maxExpect;  
+  lastValue = currentLoadSum * 100 / maxExpect;
+  ret = lastValue;
   MUTEX_UNLOCK(&statusMutex);
-  return currentLoadSum * 100 / maxExpect;
+  return ret;
 }
 
 /**
@@ -699,10 +715,12 @@
   static unsigned long long overload;
   static unsigned long long lastSum;
   static cron_t lastCall;
+  static int lastValue;
   cron_t now;
   unsigned long long maxExpect;
   unsigned long long currentLoadSum;
   int i;
+  int ret;
   
   MUTEX_LOCK(&statusMutex);
   currentLoadSum = globalTrafficBetweenProc.last_in;
@@ -720,6 +738,17 @@
     MUTEX_UNLOCK(&statusMutex);
     return -1;
   }
+  if (maxNetDownBPS == 0) {
+    MUTEX_UNLOCK(&statusMutex);
+    return -1;
+  }
+  if (lastCall - now < cronSECONDS) {
+    /* increase last load proportional to difference in
+       data transmitted and in relation to the limit */
+    ret = lastValue + 100 * (currentLoadSum - lastSum) / maxNetDownBPS;
+    MUTEX_UNLOCK(&statusMutex);
+    return ret;
+  }
   currentLoadSum += overload;
   maxExpect = ( (lastCall - now) * maxNetDownBPS ) / cronSECONDS;
   lastCall = now;
@@ -727,8 +756,10 @@
     overload = 0;
   else 
     overload = currentLoadSum - maxExpect;  
+  lastValue = currentLoadSum * 100 / maxExpect;
+  ret = lastValue;
   MUTEX_UNLOCK(&statusMutex);
-  return currentLoadSum * 100 / maxExpect;
+  return ret;
 }
 
 /**





reply via email to

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