diff options
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 32 |
2 files changed, 29 insertions, 9 deletions
@@ -3,12 +3,6 @@ | |||
3 | - trust: need *fast* way to check/update trust in peers | 3 | - trust: need *fast* way to check/update trust in peers |
4 | (async peerinfo would not be right; certainly not with the current API) | 4 | (async peerinfo would not be right; certainly not with the current API) |
5 | * TOPOLOGY: [CG] | 5 | * TOPOLOGY: [CG] |
6 | - needs to re-try connecting after disconnect (currently, it | ||
7 | initially triggers a connection request, but if that connection | ||
8 | fails / goes down, it does not retry in a timely fashion; | ||
9 | cause seems to be the 'greylist_after_attempt' being set to 1h, | ||
10 | which is rather long -- and should probably be adjusted based on | ||
11 | the number of connections / known peers & use some form of back-off) | ||
12 | - If the topology daemon crashes, peers that were put on the | 6 | - If the topology daemon crashes, peers that were put on the |
13 | blacklist with transport will never be removed from it (until | 7 | blacklist with transport will never be removed from it (until |
14 | transport service dies); we should use the blacklist notification | 8 | transport service dies); we should use the blacklist notification |
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) && |