From af0a30c9c5d84cee834494d43f13e676b5e2aa15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Tue, 26 Jun 2018 20:41:04 -0400 Subject: [PATCH 1/2] dhtrunner: drop oldest packet if queue is full --- src/dhtrunner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dhtrunner.cpp b/src/dhtrunner.cpp index 6084f1d5..69c71820 100644 --- a/src/dhtrunner.cpp +++ b/src/dhtrunner.cpp @@ -526,7 +526,7 @@ DhtRunner::startNetwork(const SockAddr sin4, const SockAddr sin6) std::lock_guard lck(sock_mtx); if (rcv.size() >= RX_QUEUE_MAX_SIZE) { std::cerr << "Dropping packet: queue is full!" << std::endl; - continue; + rcv.pop(); } rcv.emplace(ReceivedPacket {Blob {buf.begin(), buf.begin()+rc+1}, SockAddr(from, from_len), clock::now()}); } From ffbb9e23ef65fc5b6b7323d8183d9ea70c80b005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Wed, 27 Jun 2018 11:54:15 -0400 Subject: [PATCH 2/2] dht: show usage at the end, print max store size --- src/dht.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dht.cpp b/src/dht.cpp index 46ff08f3..6bd42e26 100644 --- a/src/dht.cpp +++ b/src/dht.cpp @@ -1585,11 +1585,6 @@ Dht::getStorageLog() const std::stringstream out; for (const auto& s : store) out << printStorageLog(s); - out << "Total " << store.size() << " storages, " << total_values << " values ("; - if (total_store_size < 1024) - out << total_store_size << " bytes)"; - else - out << (total_store_size/1024) << " KB)"; out << std::endl << std::endl; std::multimap q_map; for (const auto& ip : store_quota) @@ -1598,6 +1593,12 @@ Dht::getStorageLog() const for (auto ip = q_map.rbegin(); ip != q_map.rend(); ++ip) out << "IP " << ip->second->toString() << " uses " << ip->first << " bytes" << std::endl; out << std::endl; + out << "Total " << store.size() << " storages, " << total_values << " values ("; + if (total_store_size < 1024) + out << total_store_size << " bytes)"; + else + out << (total_store_size/1024) << " / " << (max_store_size/1024) << " KB)"; + out << std::endl; return out.str(); }