gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r8437 - in GNUnet: . src/server


From: gnunet
Subject: [GNUnet-SVN] r8437 - in GNUnet: . src/server
Date: Mon, 27 Apr 2009 14:22:58 -0600

Author: durner
Date: 2009-04-27 14:22:57 -0600 (Mon, 27 Apr 2009)
New Revision: 8437

Modified:
   GNUnet/ChangeLog
   GNUnet/src/server/connection.c
Log:
be less harsh about terminating low-traffic connections

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2009-04-27 19:06:33 UTC (rev 8436)
+++ GNUnet/ChangeLog    2009-04-27 20:22:57 UTC (rev 8437)
@@ -1,3 +1,7 @@
+Mon Apr 27 22:18:19 CEST 2009
+  Monitor low-traffic connections over a longer period
+  of time before terminating them.
+
 Fri Feb 27 22:05:50 MST 2009
        Releasing 0.8.0c.
 

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2009-04-27 19:06:33 UTC (rev 8436)
+++ GNUnet/src/server/connection.c      2009-04-27 20:22:57 UTC (rev 8437)
@@ -168,6 +168,26 @@
 #define MAX_VIOLATIONS 10
 
 /**
+ * The maximum value for the low-speed counter
+ */
+#define LOW_SPEED_CTR_MAX CHAR_MAX
+
+/**
+ * Kill low-speed connection after x samples
+ */
+#define LOW_SPEED_CTR_THRESHOLD 10
+
+/**
+ * Amount by which we increase the low-speed counter at a time.
+ */
+#define LOW_SPEED_CTR_INCREMENT (LOW_SPEED_CTR_MAX / (LOW_SPEED_CTR_THRESHOLD 
+ 1))
+
+/**
+ * Amount by which we decrease the low-speed counter at a time.
+ */
+#define LOW_SPEED_CTR_DECREMENT (LOW_SPEED_CTR_INCREMENT / 3)
+
+/**
  * Status constants
  *
  * Protocol goes like this:
@@ -550,6 +570,11 @@
   unsigned int violations;
 
   /**
+   * How often was the connection considered low-speed recently?
+   */
+  unsigned char low_speed_ctr;
+
+  /**
    * are we currently in "sendBuffer" for this entry?
    */
   int inSendBuffer;
@@ -2814,8 +2839,23 @@
   for (u = 0; u < activePeerCount; u++)
     {
       BufferEntry *be = entries[u];
+      double factor;
 
-      if (be->idealized_limit < MIN_BPM_PER_PEER)
+      /* update low-speed counter */
+      factor = timeDifference / (double) GNUNET_CRON_SECONDS;
+      if (factor > 1)
+        factor = 1;
+
+      if (be->idealized_limit < MIN_BPM_PER_PEER && be->max_bpm < 
MIN_BPM_PER_PEER)
+        be->low_speed_ctr += (LOW_SPEED_CTR_INCREMENT * factor);
+      else if (be->low_speed_ctr > LOW_SPEED_CTR_DECREMENT * factor)
+        be->low_speed_ctr -= (LOW_SPEED_CTR_DECREMENT * factor);
+      else
+        be->low_speed_ctr = 0;
+
+      /* terminate connection if not overly useful */
+      if (be->low_speed_ctr >
+          LOW_SPEED_CTR_THRESHOLD * LOW_SPEED_CTR_INCREMENT)
         {
 #if DEBUG_CONNECTION
           IF_GELOG (ectx,





reply via email to

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