Browse Source

limit outgoing queue size

pull/572/head
orignal 9 years ago
parent
commit
c664be52d7
  1. 8
      NTCPSession.cpp
  2. 1
      NTCPSession.h

8
NTCPSession.cpp

@ -712,10 +712,18 @@ namespace transport
{ {
if (m_IsTerminated) return; if (m_IsTerminated) return;
if (m_IsSending) if (m_IsSending)
{
if (m_SendQueue.size () < NTCP_MAX_OUTGOING_QUEUE_SIZE)
{ {
for (auto it: msgs) for (auto it: msgs)
m_SendQueue.push_back (it); m_SendQueue.push_back (it);
} }
else
{
LogPrint (eLogWarning, "NTCP: outgoing messages queue size exceeds ", NTCP_MAX_OUTGOING_QUEUE_SIZE);
Terminate ();
}
}
else else
Send (msgs); Send (msgs);
} }

1
NTCPSession.h

@ -40,6 +40,7 @@ namespace transport
const size_t NTCP_DEFAULT_PHASE3_SIZE = 2/*size*/ + i2p::data::DEFAULT_IDENTITY_SIZE/*387*/ + 4/*ts*/ + 15/*padding*/ + 40/*signature*/; // 448 const size_t NTCP_DEFAULT_PHASE3_SIZE = 2/*size*/ + i2p::data::DEFAULT_IDENTITY_SIZE/*387*/ + 4/*ts*/ + 15/*padding*/ + 40/*signature*/; // 448
const int NTCP_BAN_EXPIRATION_TIMEOUT = 70; // in second const int NTCP_BAN_EXPIRATION_TIMEOUT = 70; // in second
const int NTCP_CLOCK_SKEW = 60; // in seconds const int NTCP_CLOCK_SKEW = 60; // in seconds
const int NTCP_MAX_OUTGOING_QUEUE_SIZE = 200; // how many messages we can queue up
class NTCPServer; class NTCPServer;
class NTCPSession: public TransportSession, public std::enable_shared_from_this<NTCPSession> class NTCPSession: public TransportSession, public std::enable_shared_from_this<NTCPSession>

Loading…
Cancel
Save