gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5184 - in GNUnet/src/applications: advertising topology_de


From: gnunet
Subject: [GNUnet-SVN] r5184 - in GNUnet/src/applications: advertising topology_default topology_f2f
Date: Fri, 29 Jun 2007 22:35:14 -0600 (MDT)

Author: grothoff
Date: 2007-06-29 22:35:14 -0600 (Fri, 29 Jun 2007)
New Revision: 5184

Modified:
   GNUnet/src/applications/advertising/bootstrap.c
   GNUnet/src/applications/topology_default/topology.c
   GNUnet/src/applications/topology_f2f/topology.c
Log:
trying to make sure topology is not too pushy about establishing connections

Modified: GNUnet/src/applications/advertising/bootstrap.c
===================================================================
--- GNUnet/src/applications/advertising/bootstrap.c     2007-06-30 02:57:52 UTC 
(rev 5183)
+++ GNUnet/src/applications/advertising/bootstrap.c     2007-06-30 04:35:14 UTC 
(rev 5184)
@@ -143,9 +143,9 @@
   char * data;
 
   now = get_time();
-  if (coreAPI->forAllConnectedNodes(NULL, NULL) >= 4) {
+  if (coreAPI->forAllConnectedNodes(NULL, NULL) >= 3) {
     /* still change delta and lastTest; even
-       if the peer _briefly_ drops below 5
+       if the peer _briefly_ drops below 3
        connections, we don't want it to immediately
        go for the hostlist... */
     delta = 5 * cronMINUTES;

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-06-30 02:57:52 UTC 
(rev 5183)
+++ GNUnet/src/applications/topology_default/topology.c 2007-06-30 04:35:14 UTC 
(rev 5184)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004, 2006 Christian Grothoff (and other 
contributing authors)
+     (C) 2001, 2002, 2003, 2004, 2006, 2007 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -268,6 +268,8 @@
   }
 }
 
+#define MAX_PEERS_PER_SLOT 10
+
 /**
  * Call this method periodically to decrease liveness of hosts.
  *
@@ -285,13 +287,12 @@
                                                 "DISABLE-AUTOCONNECT",
                                                 NO);
   slotCount = coreAPI->getSlotCount();
-  if (saturation > 0.001)
-    minint = (int) 1 / saturation;
-  else
-    minint = 10;
-  if (minint == 0)
-    minint = 1;
-  if (NO == autoconnect) {
+  if ( (NO == autoconnect) &&
+       (saturation < 1) ) {
+    if (saturation * MAX_PEERS_PER_SLOT >= 1)
+      minint = (unsigned int) (1 / saturation);
+    else
+      minint = MAX_PEERS_PER_SLOT; /* never put more than 10 peers into a slot 
*/
     for (i=slotCount-1;i>=0;i--) {
       if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
        continue;
@@ -299,9 +300,8 @@
        scanForHosts(i);
     }
   }
-  active = coreAPI->forAllConnectedNodes
-    (&checkNeedForPing,
-     NULL);
+  active = coreAPI->forAllConnectedNodes(&checkNeedForPing,
+                                        NULL);
   saturation = 1.0 * active / slotCount;
 }
 

Modified: GNUnet/src/applications/topology_f2f/topology.c
===================================================================
--- GNUnet/src/applications/topology_f2f/topology.c     2007-06-30 02:57:52 UTC 
(rev 5183)
+++ GNUnet/src/applications/topology_f2f/topology.c     2007-06-30 04:35:14 UTC 
(rev 5184)
@@ -298,27 +298,19 @@
   int i;
   int slotCount;
   int active;
-  unsigned int minint;
 
   slotCount = coreAPI->getSlotCount();
-  if (saturation > 0.001)
-    minint = (int) 1 / saturation;
-  else
-    minint = 10;
-  if (minint == 0)
-    minint = 1;
-  for (i=slotCount-1;i>=0;i--) {
-    if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
-      continue;
-
-    if ( (minint > coreAPI->isSlotUsed(i)) &&
-        (0 == coreAPI->isSlotUsed(i)) )
-      scanForHosts(i);
+  if (saturation < 1) {
+    for (i=slotCount-1;i>=0;i--) {
+      if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
+       continue;
+      if (0 == coreAPI->isSlotUsed(i)) 
+       scanForHosts(i);
+    }
   }
-  active = coreAPI->forAllConnectedNodes
-    (&checkNeedForPing,
-     NULL);
-  saturation = 1.0 * slotCount / active;
+  active = coreAPI->forAllConnectedNodes(&checkNeedForPing,
+                                        NULL);
+  saturation = 1.0 * active / slotCount;
 }
 
 static int estimateNetworkSize() {





reply via email to

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