Skip to content
Snippets Groups Projects
Commit a1fc266e authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dhtrunner: add max rx queue size

parent 3e3679be
Branches
Tags
No related merge requests found
......@@ -42,6 +42,7 @@
namespace dht {
constexpr std::chrono::seconds DhtRunner::BOOTSTRAP_PERIOD;
static constexpr size_t RX_QUEUE_MAX_SIZE = 1024 * 16;
struct DhtRunner::Listener {
size_t tokenClassicDht;
......@@ -523,6 +524,10 @@ DhtRunner::startNetwork(const SockAddr sin4, const SockAddr sin6)
if (rc > 0) {
{
std::lock_guard<std::mutex> lck(sock_mtx);
if (rcv.size() >= RX_QUEUE_MAX_SIZE) {
std::cerr << "Dropping packet: queue is full!" << std::endl;
continue;
}
rcv.emplace(ReceivedPacket {Blob {buf.begin(), buf.begin()+rc+1}, SockAddr(from, from_len), clock::now()});
}
cv.notify_all();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment