gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33972 - gnunet/src/topology


From: gnunet
Subject: [GNUnet-SVN] r33972 - gnunet/src/topology
Date: Thu, 17 Jul 2014 10:35:20 +0200

Author: wachs
Date: 2014-07-17 10:35:20 +0200 (Thu, 17 Jul 2014)
New Revision: 33972

Modified:
   gnunet/src/topology/gnunet-daemon-topology.c
Log:
per peer back-off for transport connect attempts


Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c        2014-07-17 08:02:44 UTC 
(rev 33971)
+++ gnunet/src/topology/gnunet-daemon-topology.c        2014-07-17 08:35:20 UTC 
(rev 33972)
@@ -127,6 +127,11 @@
   struct GNUNET_TIME_Absolute filter_expiration;
 
   /**
+   * When should try next connection attempt?
+   */
+  struct GNUNET_TIME_Absolute  next_connect_attempt;
+
+  /**
    * ID of task we use to wait for the time to send the next HELLO
    * to this peer.
    */
@@ -246,7 +251,7 @@
  * is rather simple.
  *
  * @param cls closure
- * @param pid peer to approve or disapproave
+ * @param pid peer to approve or disapprove
  * @return GNUNET_OK if the connection is allowed
  */
 static int
@@ -384,6 +389,12 @@
   rem = GNUNET_TIME_relative_max (rem, GREYLIST_AFTER_ATTEMPT_MIN);
   rem = GNUNET_TIME_relative_min (rem, GREYLIST_AFTER_ATTEMPT_MAX);
   pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem);
+
+  pos->next_connect_attempt = GNUNET_TIME_absolute_add 
(GNUNET_TIME_absolute_get(),
+      GNUNET_TIME_relative_multiply (MAX_CONNECT_FREQUENCY_DELAY, 
pos->connect_attempts));
+  pos->next_connect_attempt = GNUNET_TIME_absolute_min 
(pos->next_connect_attempt,
+      GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), 
MIN_CONNECT_FREQUENCY_DELAY));
+
   if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK)
     GNUNET_SCHEDULER_cancel (pos->greylist_clean_task);
   pos->greylist_clean_task =
@@ -415,7 +426,14 @@
   if (GNUNET_YES == pos->is_connected)
     return;
 
-  delay = GNUNET_TIME_absolute_get_remaining (next_connect_attempt);
+  /* Try next connection attempt, when:
+   * - topology allows the next transport connection attempt
+   * and
+   * - the next connection event for this peer is allowed
+   */
+  delay = GNUNET_TIME_relative_max (GNUNET_TIME_absolute_get_remaining 
(next_connect_attempt),
+      GNUNET_TIME_absolute_get_remaining (pos->next_connect_attempt));
+
   if (delay.rel_value_us > 0)
   {
     pos->attempt_connect_task = GNUNET_SCHEDULER_add_delayed (delay,
@@ -494,6 +512,7 @@
   ret = GNUNET_new (struct Peer);
   ret->pid = *peer;
   ret->is_friend = is_friend;
+  ret->next_connect_attempt = GNUNET_TIME_absolute_get();
   if (hello != NULL)
   {
     ret->hello = GNUNET_malloc (GNUNET_HELLO_size (hello));
@@ -727,6 +746,7 @@
   }
   pos->is_connected = GNUNET_YES;
   pos->connect_attempts = 0;    /* re-set back-off factor */
+  pos->next_connect_attempt = GNUNET_TIME_absolute_get(); /* re-set back-off 
factor */
   if (pos->is_friend)
   {
     if ((friend_count == minimum_friend_count - 1) &&




reply via email to

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