mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
more listener fixes
This commit is contained in:
1 parent
284dea6755
commit
139c8a71c7
3 files changed
+15
-4
No files matched your search
+7
-2
@@ -978,6 +978,11 @@ Dht::announce(const InfoHash& id, sa_family_t af, const std::shared_ptr<Value>&
|
||||
}
|
||||
a_sr->callback = callback;
|
||||
}
|
||||
if (not sr->nodes.empty()) {
|
||||
time_t tm = sr->getNextStepTime(types, now.tv_sec);
|
||||
if (tm != 0 && (search_time == 0 || search_time > tm))
|
||||
search_time = tm;
|
||||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
@@ -1749,9 +1754,9 @@ Dht::processMessage(const uint8_t *buf, size_t buflen, const sockaddr *from, soc
|
||||
switch (message) {
|
||||
case MessageType::Error:
|
||||
if (tid.length != 4) return;
|
||||
DHT_WARN("Received error message:");
|
||||
DHT_WARN("Received error message %u from %s:", error_code, id.toString().c_str());
|
||||
DHT_WARN.logPrintable(buf, buflen);
|
||||
if (error_code == 401 && id != zeroes && tid.matches(TransPrefix::ANNOUNCE_VALUES, &ttid)) {
|
||||
if (error_code == 401 && id != zeroes && (tid.matches(TransPrefix::ANNOUNCE_VALUES, &ttid) || tid.matches(TransPrefix::LISTEN, &ttid))) {
|
||||
auto sr = findSearch(ttid, from->sa_family);
|
||||
if (!sr) return;
|
||||
DHT_WARN("Received wrong token error for known search %s", sr->id.toString().c_str());
|
||||
|
||||
+7
-2
@@ -56,7 +56,12 @@ DhtRunner::run(in_port_t port, const crypto::Identity identity, bool threaded, S
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(storage_mtx);
|
||||
if (!dht_gets.empty() || !dht_puts.empty() || !bootstrap_nodes.empty())
|
||||
if (!dht_gets.empty()
|
||||
|| !dht_puts.empty()
|
||||
|| !dht_eputs.empty()
|
||||
|| !dht_sputs.empty()
|
||||
|| !dht_listen.empty()
|
||||
|| !bootstrap_nodes.empty())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -211,7 +216,7 @@ DhtRunner::doRun(in_port_t port, const crypto::Identity identity)
|
||||
|
||||
struct timeval tv;
|
||||
fd_set readfds;
|
||||
tv.tv_sec = tosleep / 5;
|
||||
tv.tv_sec = std::min(tosleep.load(), 10l);
|
||||
tv.tv_usec = rand_delay();
|
||||
//std::cout << "Dht::rcv_thread loop " << tv.tv_sec << "." << tv.tv_usec << std::endl;
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Stopping node..." << std::endl;
|
||||
dht.join();
|
||||
|
||||
gnutls_global_deinit();
|
||||
|
||||
Reference in new issue
Block a user