Browse Source

gossipd: exponential backoff for reconnect (5 minute ceiling).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
b1498f07c5
  1. 15
      gossipd/gossip.c

15
gossipd/gossip.c

@ -1584,10 +1584,17 @@ static void connect_failed(struct io_conn *conn, struct reaching *reach)
NULL, &reach->id, diff, reach->attempts, false)));
tal_free(reach);
} else {
status_trace("Failed connected out for %s, will try again",
type_to_string(tmpctx, struct pubkey, &reach->id));
/* FIXME: Configurable timer! */
new_reltimer(&reach->daemon->timers, reach, time_from_sec(5),
unsigned int secs;
/* Exponential backoff, then every 5 minutes */
if (reach->attempts < 9)
secs = 1 << reach->attempts;
else
secs = 300;
status_trace("Failed connected out for %s, will try again in %u seconds",
type_to_string(tmpctx, struct pubkey, &reach->id),
secs);
new_reltimer(&reach->daemon->timers, reach, time_from_sec(secs),
try_connect, reach);
}
}

Loading…
Cancel
Save