dht: add connectivityChanged()

This commit is contained in:
Adrien Béraud committed 2015-07-28 16:26:35 -04:00
1 parent 3f7d2df9b1
commit f13b28fed4
4 files changed
+35

No files matched your search

+7
View File
@@ -300,6 +300,13 @@ public:
bool cancelListen(const InfoHash&, size_t token);
/**
* Inform the DHT of lower-layer connectivity changes.
* This will cause the DHT to assume an IP address change.
* The DHT will recontact neighbor nodes, re-register for listen ops etc.
*/
void connectivityChanged();
/**
* Get the list of good nodes for local storage saving purposes
* The list is ordered to minimize the back-to-work delay.
+7
View File
@@ -191,6 +191,13 @@ public:
void bootstrap(const std::vector<std::pair<sockaddr_storage, socklen_t>>& nodes);
void bootstrap(const std::vector<NodeExport>& nodes);
/**
* Inform the DHT of lower-layer connectivity changes.
* This will cause the DHT to assume an IP address change.
* The DHT will recontact neighbor nodes, re-register for listen ops etc.
*/
void connectivityChanged();
void dumpTables() const
{
std::lock_guard<std::mutex> lck(dht_mtx);
+11
View File
@@ -1705,6 +1705,17 @@ Dht::expireStorage()
}
}
void
Dht::connectivityChanged()
{
confirm_nodes_time = now;
mybucket_grow_time = now;
mybucket6_grow_time = now;
for (auto& s : searches)
for (auto& sn : s.nodes)
sn.listenStatus = {};
}
void
Dht::rotateSecrets()
{
+10
View File
@@ -445,6 +445,16 @@ DhtRunner::bootstrap(const std::vector<NodeExport>& nodes)
cv.notify_all();
}
void
DhtRunner::connectivityChanged()
{
std::lock_guard<std::mutex> lck(storage_mtx);
pending_ops.emplace([=](SecureDht& dht) {
dht.connectivityChanged();
});
cv.notify_all();
}
void
DhtRunner::findCertificate(InfoHash hash, std::function<void(const std::shared_ptr<crypto::Certificate>)> cb) {
std::lock_guard<std::mutex> lck(storage_mtx);