mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
dhtrunner: recover from network changes
Using a list of bootstrap nodes, we recover from network loss by pinging those nodes continuously until connected. Written with Simon Désaulniers.
This commit is contained in:
1 parent
bb74dc846c
commit
64118404fe
3 files changed
+131
-15
No files matched your search
+8
-8
@@ -2385,9 +2385,8 @@ Dht::getNodesStats(sa_family_t af, unsigned *good_return, unsigned *dubious_retu
|
||||
good++;
|
||||
if (n->time > n->reply_time)
|
||||
incoming++;
|
||||
} else {
|
||||
} else if (not n->isExpired())
|
||||
dubious++;
|
||||
}
|
||||
}
|
||||
if (b.cached)
|
||||
cached++;
|
||||
@@ -2669,11 +2668,12 @@ Dht::neighbourhoodMaintenance(RoutingTable& list)
|
||||
q = r;
|
||||
}
|
||||
|
||||
/* Since our node-id is the same in both DHTs, it's probably
|
||||
profitable to query both families. */
|
||||
auto n = q->randomNode();
|
||||
if (n) {
|
||||
DHT_LOG.DEBUG("[find %s IPv%c] sending find for neighborhood maintenance.", id.toString().c_str(), q->af == AF_INET6 ? '6' : '4');
|
||||
DHT_LOG.DEBUG("[find %s IPv%c] sending find for neighborhood maintenance.",
|
||||
id.toString().c_str(), q->af == AF_INET6 ? '6' : '4');
|
||||
/* Since our node-id is the same in both DHTs, it's probably
|
||||
profitable to query both families. */
|
||||
network_engine.sendFindNode(n, id, network_engine.want(), nullptr, nullptr);
|
||||
}
|
||||
|
||||
@@ -2876,9 +2876,9 @@ Dht::confirmNodes()
|
||||
case is roughly 27 seconds, assuming the table is 22 bits deep.
|
||||
We want to keep a margin for neighborhood maintenance, so keep
|
||||
this within 25 seconds. */
|
||||
auto time_dis = soon ?
|
||||
uniform_duration_distribution<> {seconds(5) , seconds(25)}
|
||||
: uniform_duration_distribution<> {seconds(60), seconds(180)};
|
||||
auto time_dis = soon
|
||||
? uniform_duration_distribution<> {seconds(5) , seconds(25)}
|
||||
: uniform_duration_distribution<> {seconds(60), seconds(180)};
|
||||
auto confirm_nodes_time = now + time_dis(rd);
|
||||
|
||||
nextNodesConfirmation = scheduler.add(confirm_nodes_time, std::bind(&Dht::confirmNodes, this));
|
||||
|
||||
Reference in new issue
Block a user