Browse Source

prevent log spamming with no_descriptors error

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1825/head
R4SAS 2 years ago
parent
commit
857df5c734
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 31
      libi2pd/NTCP2.cpp
  2. 4
      libi2pd/NTCP2.h

31
libi2pd/NTCP2.cpp

@ -1424,16 +1424,17 @@ namespace transport
else else
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ());
} }
else else if (error == boost::asio::error::no_descriptors)
{
LogPrint (eLogError, "NTCP2: Accept error ", error.message ());
if (error == boost::asio::error::no_descriptors)
{ {
i2p::context.SetError (eRouterErrorNoDescriptors); i2p::context.SetError (eRouterErrorNoDescriptors);
// TODO if (m_NoFileExhaustTimestamp < i2p::util::GetSecondsSinceEpoch () - NTCP2_DESCRIPTORS_EXHAUST_TIMEOUT)
return; {
m_NoFileExhaustTimestamp = i2p::util::GetSecondsSinceEpoch ();
LogPrint (eLogWarning, "NTCP2: WARNING! i2pd met file descriptors exhaustion! Please check your nofile limits!");
} }
} }
else
LogPrint (eLogError, "NTCP2: Accept error ", error.message ());
if (error != boost::asio::error::operation_aborted) if (error != boost::asio::error::operation_aborted)
{ {
@ -1463,22 +1464,26 @@ namespace transport
} }
} }
else else
LogPrint (eLogError, "NTCP2: Connected from error ", ec.message ()); LogPrint (eLogError, "NTCP2: Connected from ipv6 error: ", ec.message ());
} }
else else if (error == boost::asio::error::no_descriptors)
{
LogPrint (eLogError, "NTCP2: Accept ipv6 error ", error.message ());
if (error == boost::asio::error::no_descriptors)
{ {
i2p::context.SetErrorV6 (eRouterErrorNoDescriptors); i2p::context.SetErrorV6 (eRouterErrorNoDescriptors);
// TODO if (m_NoFileExhaustTimestamp < i2p::util::GetSecondsSinceEpoch () - NTCP2_DESCRIPTORS_EXHAUST_TIMEOUT)
return; {
m_NoFileExhaustTimestamp = i2p::util::GetSecondsSinceEpoch ();
LogPrint (eLogWarning, "NTCP2: WARNING! i2pd met file descriptors exhaustion! Please check your nofile limits!");
} }
} }
else
LogPrint (eLogError, "NTCP2: Accept ipv6 error: ", error.message ());
if (error != boost::asio::error::operation_aborted) if (error != boost::asio::error::operation_aborted)
{ {
if (!conn) // connection is used, create new one
conn = std::make_shared<NTCP2Session> (*this); conn = std::make_shared<NTCP2Session> (*this);
else // reuse failed
conn->Close ();
m_NTCP2V6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAcceptV6, this, m_NTCP2V6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAcceptV6, this,
conn, std::placeholders::_1)); conn, std::placeholders::_1));
} }

4
libi2pd/NTCP2.h

@ -43,6 +43,8 @@ namespace transport
const int NTCP2_CLOCK_SKEW = 60; // in seconds const int NTCP2_CLOCK_SKEW = 60; // in seconds
const int NTCP2_MAX_OUTGOING_QUEUE_SIZE = 500; // how many messages we can queue up const int NTCP2_MAX_OUTGOING_QUEUE_SIZE = 500; // how many messages we can queue up
const int NTCP2_DESCRIPTORS_EXHAUST_TIMEOUT = 60; // 1 minute
enum NTCP2BlockType enum NTCP2BlockType
{ {
eNTCP2BlkDateTime = 0, eNTCP2BlkDateTime = 0,
@ -286,6 +288,8 @@ namespace transport
std::unique_ptr<boost::asio::ip::tcp::endpoint> m_ProxyEndpoint; std::unique_ptr<boost::asio::ip::tcp::endpoint> m_ProxyEndpoint;
std::shared_ptr<boost::asio::ip::tcp::endpoint> m_Address4, m_Address6, m_YggdrasilAddress; std::shared_ptr<boost::asio::ip::tcp::endpoint> m_Address4, m_Address6, m_YggdrasilAddress;
uint64_t m_NoFileExhaustTimestamp;
public: public:
// for HTTP/I2PControl // for HTTP/I2PControl

Loading…
Cancel
Save