From 57310fdbd698e7bce166abe653e6b51e4f98e6b7 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 3 Jan 2017 11:52:28 -0500 Subject: [PATCH] reduced memory footprint --- NTCPSession.cpp | 7 +++++-- NTCPSession.h | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NTCPSession.cpp b/NTCPSession.cpp index 712006c4..dca322c3 100644 --- a/NTCPSession.cpp +++ b/NTCPSession.cpp @@ -525,7 +525,7 @@ namespace transport memcpy (m_ReceiveBuffer, nextBlock, m_ReceiveBufferOffset); // try to read more - if (numReloads < 5) + if (numReloads < 16) // ~16K { boost::system::error_code ec; size_t moreBytes = m_Socket.available(ec); @@ -541,9 +541,12 @@ namespace transport return; } m_NumReceivedBytes += moreBytes; + i2p::transport::transports.UpdateReceivedBytes (bytes_transferred); m_ReceiveBufferOffset += moreBytes; numReloads++; - } + } + else + break; // no more data } } while (m_ReceiveBufferOffset >= 16); diff --git a/NTCPSession.h b/NTCPSession.h index b02543be..a5d6f99f 100644 --- a/NTCPSession.h +++ b/NTCPSession.h @@ -35,12 +35,11 @@ namespace transport }; const size_t NTCP_MAX_MESSAGE_SIZE = 16384; - const size_t NTCP_BUFFER_SIZE = 4160; // fits 4 tunnel messages (4*1028) + const size_t NTCP_BUFFER_SIZE = 1028; // fits 1 tunnel data message const int NTCP_CONNECT_TIMEOUT = 5; // 5 seconds const int NTCP_TERMINATION_TIMEOUT = 120; // 2 minutes const int NTCP_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds 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_CLOCK_SKEW = 60; // in seconds const int NTCP_MAX_OUTGOING_QUEUE_SIZE = 200; // how many messages we can queue up