summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-23 22:35:17 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-23 22:35:17 +0100
commit41cf6b6ef4e89a72a8390b5689f03796c3400bad (patch)
tree19129a534a3cbd5556e876c8b9227784319be5ae /src/fastd.c
parentca79dc4bdd7aeb449321029facf30c333be10337 (diff)
downloadfastd-41cf6b6ef4e89a72a8390b5689f03796c3400bad.tar
fastd-41cf6b6ef4e89a72a8390b5689f03796c3400bad.zip
After a peer was ignored because of a peer limit, always re-resolve the first remote
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 634c736..8d82bdb 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -447,20 +447,26 @@ static void handle_handshake_queue(fastd_context_t *ctx) {
fastd_peer_schedule_handshake_default(ctx, peer);
if (!fastd_peer_may_connect(ctx, peer)) {
- peer->next_remote = peer->remotes;
- peer->next_remote->current_address = 0;
+ if (peer->next_remote != NULL) {
+ pr_debug(ctx, "disabling handshakes with %P because of the peer limit", peer);
+ peer->next_remote = NULL;
+ }
+
return;
}
- send_handshake(ctx, peer);
+ if (peer->next_remote) {
+ send_handshake(ctx, peer);
- if (fastd_peer_is_established(peer))
- return;
+ if (fastd_peer_is_established(peer))
+ return;
- if (++peer->next_remote->current_address < peer->next_remote->n_addresses)
- return;
+ if (++peer->next_remote->current_address < peer->next_remote->n_addresses)
+ return;
+
+ peer->next_remote = peer->next_remote->next;
+ }
- peer->next_remote = peer->next_remote->next;
if (!peer->next_remote)
peer->next_remote = peer->remotes;