aboutsummaryrefslogtreecommitdiff
path: root/src/topology
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-07-17 08:02:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-07-17 08:02:44 +0000
commit05e2e90dc4b9c9118c42e4ad4ab6f1333597045d (patch)
tree84b925086accaf0cefd69f175ecc81f2a361e822 /src/topology
parent09ce1fa7794a5aa8a94f80f0392e83691bcfea1f (diff)
downloadgnunet-05e2e90dc4b9c9118c42e4ad4ab6f1333597045d.tar.gz
gnunet-05e2e90dc4b9c9118c42e4ad4ab6f1333597045d.zip
fix docu, make code readable, remove unclear FIXME, add max frequency
Diffstat (limited to 'src/topology')
-rw-r--r--src/topology/gnunet-daemon-topology.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index ba78f25dd..147e7332a 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -40,6 +40,11 @@
40#define MAX_CONNECT_FREQUENCY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) 40#define MAX_CONNECT_FREQUENCY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250)
41 41
42/** 42/**
43 * Maximum delay allowed delay between calls to GNUNET_TRANSPORT_try_connect.
44 */
45#define MIN_CONNECT_FREQUENCY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 2500)
46
47/**
43 * For how long do we blacklist a peer after a failed connection 48 * For how long do we blacklist a peer after a failed connection
44 * attempt? This is the baseline factor which is then multiplied by 49 * attempt? This is the baseline factor which is then multiplied by
45 * two to the power of the number of failed attempts. 50 * two to the power of the number of failed attempts.
@@ -373,7 +378,9 @@ attempt_connect (struct Peer *pos)
373 rem = GNUNET_TIME_relative_divide (rem, target_connection_count); 378 rem = GNUNET_TIME_relative_divide (rem, target_connection_count);
374 if (pos->connect_attempts > 30) 379 if (pos->connect_attempts > 30)
375 pos->connect_attempts = 30; 380 pos->connect_attempts = 30;
376 rem = GNUNET_TIME_relative_multiply (rem, 1 << (++pos->connect_attempts)); 381 else
382 pos->connect_attempts ++;
383 rem = GNUNET_TIME_relative_multiply (rem, 1 << pos->connect_attempts);
377 rem = GNUNET_TIME_relative_max (rem, GREYLIST_AFTER_ATTEMPT_MIN); 384 rem = GNUNET_TIME_relative_max (rem, GREYLIST_AFTER_ATTEMPT_MIN);
378 rem = GNUNET_TIME_relative_min (rem, GREYLIST_AFTER_ATTEMPT_MAX); 385 rem = GNUNET_TIME_relative_min (rem, GREYLIST_AFTER_ATTEMPT_MAX);
379 pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); 386 pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem);
@@ -387,7 +394,7 @@ attempt_connect (struct Peer *pos)
387 gettext_noop 394 gettext_noop
388 ("# connect requests issued to transport"), 1, 395 ("# connect requests issued to transport"), 1,
389 GNUNET_NO); 396 GNUNET_NO);
390 GNUNET_TRANSPORT_try_connect (transport, &pos->pid, NULL, NULL); /*FIXME TRY_CONNECT change */ 397 GNUNET_TRANSPORT_try_connect (transport, &pos->pid, NULL, NULL);
391} 398}
392 399
393 400
@@ -407,6 +414,7 @@ do_attempt_connect (void *cls,
407 pos->attempt_connect_task = GNUNET_SCHEDULER_NO_TASK; 414 pos->attempt_connect_task = GNUNET_SCHEDULER_NO_TASK;
408 if (GNUNET_YES == pos->is_connected) 415 if (GNUNET_YES == pos->is_connected)
409 return; 416 return;
417
410 delay = GNUNET_TIME_absolute_get_remaining (next_connect_attempt); 418 delay = GNUNET_TIME_absolute_get_remaining (next_connect_attempt);
411 if (delay.rel_value_us > 0) 419 if (delay.rel_value_us > 0)
412 { 420 {
@@ -751,8 +759,7 @@ try_add_peers (void *cls, const struct GNUNET_PeerIdentity * pid, void *value)
751 759
752 760
753/** 761/**
754 * Last task run during shutdown. Disconnects us from 762 * Add peers and schedule connection attempt
755 * the transport and core.
756 * 763 *
757 * @param cls unused, NULL 764 * @param cls unused, NULL
758 * @param tc scheduler context 765 * @param tc scheduler context