diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-17 22:54:36 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-17 22:54:36 +0000 |
commit | e8bc962b2ed43e194ba124537573da236786e82c (patch) | |
tree | ba3acb5402a7aaaf08ceeadebb4047d872c3cd2c /src/topology | |
parent | 967418d0b309a8efb8d552ced8359bfe2d444e45 (diff) | |
download | gnunet-e8bc962b2ed43e194ba124537573da236786e82c.tar.gz gnunet-e8bc962b2ed43e194ba124537573da236786e82c.zip |
use back-off and higher-frequency re-tries to start with for creating connections
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 3a2a421d4..b175d82ae 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -41,13 +41,25 @@ | |||
41 | * For how long do we blacklist a peer after a failed connection | 41 | * For how long do we blacklist a peer after a failed connection |
42 | * attempt? | 42 | * attempt? |
43 | */ | 43 | */ |
44 | #define GREYLIST_AFTER_ATTEMPT GNUNET_TIME_UNIT_HOURS | 44 | #define GREYLIST_AFTER_ATTEMPT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * For how long do we blacklist a friend after a failed connection | 47 | * For how long do we blacklist a friend after a failed connection |
48 | * attempt? | 48 | * attempt? |
49 | */ | 49 | */ |
50 | #define GREYLIST_AFTER_ATTEMPT_FRIEND GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 50 | #define GREYLIST_AFTER_ATTEMPT_FRIEND GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2) |
51 | |||
52 | /** | ||
53 | * For how long do we blacklist anyone under any cirumstances after a failed connection | ||
54 | * attempt? | ||
55 | */ | ||
56 | #define GREYLIST_AFTER_ATTEMPT_MIN GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | ||
57 | |||
58 | /** | ||
59 | * For how long do we blacklist anyone under any cirumstances after a failed connection | ||
60 | * attempt? | ||
61 | */ | ||
62 | #define GREYLIST_AFTER_ATTEMPT_MAX GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 18) | ||
51 | 63 | ||
52 | /** | 64 | /** |
53 | * How often do we at most advertise any HELLO to a peer? | 65 | * How often do we at most advertise any HELLO to a peer? |
@@ -127,6 +139,11 @@ struct Peer | |||
127 | GNUNET_SCHEDULER_TaskIdentifier greylist_clean_task; | 139 | GNUNET_SCHEDULER_TaskIdentifier greylist_clean_task; |
128 | 140 | ||
129 | /** | 141 | /** |
142 | * How often have we tried so far? | ||
143 | */ | ||
144 | unsigned int connect_attempts; | ||
145 | |||
146 | /** | ||
130 | * Is this peer listed here because he is a friend? | 147 | * Is this peer listed here because he is a friend? |
131 | */ | 148 | */ |
132 | int is_friend; | 149 | int is_friend; |
@@ -512,7 +529,15 @@ attempt_connect (struct Peer *pos) | |||
512 | rem = GREYLIST_AFTER_ATTEMPT_FRIEND; | 529 | rem = GREYLIST_AFTER_ATTEMPT_FRIEND; |
513 | else | 530 | else |
514 | rem = GREYLIST_AFTER_ATTEMPT; | 531 | rem = GREYLIST_AFTER_ATTEMPT; |
515 | /* FIXME: do exponential back-off? */ | 532 | rem = GNUNET_TIME_relative_multiply (rem, connection_count); |
533 | rem = GNUNET_TIME_relative_divide (rem, target_connection_count); | ||
534 | if (pos->connect_attempts > 30) | ||
535 | pos->connect_attempts = 30; | ||
536 | rem = GNUNET_TIME_relative_multiply (rem, 1 << (++pos->connect_attempts)); | ||
537 | rem = GNUNET_TIME_relative_max (rem, | ||
538 | GREYLIST_AFTER_ATTEMPT_MIN); | ||
539 | rem = GNUNET_TIME_relative_min (rem, | ||
540 | GREYLIST_AFTER_ATTEMPT_MAX); | ||
516 | pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); | 541 | pos->greylisted_until = GNUNET_TIME_relative_to_absolute (rem); |
517 | if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) | 542 | if (pos->greylist_clean_task != GNUNET_SCHEDULER_NO_TASK) |
518 | GNUNET_SCHEDULER_cancel (sched, | 543 | GNUNET_SCHEDULER_cancel (sched, |
@@ -857,6 +882,7 @@ connect_notify (void *cls, | |||
857 | pos->greylisted_until.value = 0; /* remove greylisting */ | 882 | pos->greylisted_until.value = 0; /* remove greylisting */ |
858 | } | 883 | } |
859 | pos->is_connected = GNUNET_YES; | 884 | pos->is_connected = GNUNET_YES; |
885 | pos->connect_attempts = 0; /* re-set back-off factor */ | ||
860 | if (pos->is_friend) | 886 | if (pos->is_friend) |
861 | { | 887 | { |
862 | if ( (friend_count == minimum_friend_count - 1) && | 888 | if ( (friend_count == minimum_friend_count - 1) && |