From 8f41776858aeb9f0bcb85898978edb61124ebe00 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 28 Sep 2018 09:54:42 -0400 Subject: [PATCH] check send queue size --- libi2pd/NTCP2.cpp | 7 ++++++- libi2pd/NTCP2.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libi2pd/NTCP2.cpp b/libi2pd/NTCP2.cpp index 1e617a8a..ca6dc858 100644 --- a/libi2pd/NTCP2.cpp +++ b/libi2pd/NTCP2.cpp @@ -1055,7 +1055,12 @@ namespace transport for (auto it: msgs) m_SendQueue.push_back (it); if (!m_IsSending) - SendQueue (); + SendQueue (); + else if (m_SendQueue.size () > NTCP2_MAX_OUTGOING_QUEUE_SIZE) + { + LogPrint (eLogWarning, "NTCP2: outgoing messages queue size exceeds ", NTCP2_MAX_OUTGOING_QUEUE_SIZE); + Terminate (); + } } void NTCP2Session::SendLocalRouterInfo () diff --git a/libi2pd/NTCP2.h b/libi2pd/NTCP2.h index f11be500..7db6e8bf 100644 --- a/libi2pd/NTCP2.h +++ b/libi2pd/NTCP2.h @@ -39,6 +39,7 @@ namespace transport const int NTCP2_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds const int NTCP2_CLOCK_SKEW = 60; // in seconds + const int NTCP2_MAX_OUTGOING_QUEUE_SIZE = 500; // how many messages we can queue up enum NTCP2BlockType {