diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index 23cf16f3..b4ddc109 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -116,6 +116,7 @@ namespace tunnel if (!isFollowOnFragment) // create new incomlete message { m.nextFragmentNum = 1; + m.receiveTime = i2p::util::GetMillisecondsSinceEpoch (); auto ret = m_IncompleteMessages.insert (std::pair(msgID, m)); if (ret.second) HandleOutOfSequenceFragments (msgID, ret.first->second); @@ -284,6 +285,14 @@ namespace tunnel else ++it; } + // incomplete messages + for (auto it = m_IncompleteMessages.begin (); it != m_IncompleteMessages.end ();) + { + if (ts > it->second.receiveTime + i2p::I2NP_MESSAGE_EXPIRATION_TIMEOUT) + it = m_IncompleteMessages.erase (it); + else + ++it; + } } } } diff --git a/TunnelEndpoint.h b/TunnelEndpoint.h index 60c4fc0a..e13ced34 100644 --- a/TunnelEndpoint.h +++ b/TunnelEndpoint.h @@ -15,6 +15,7 @@ namespace tunnel { struct TunnelMessageBlockEx: public TunnelMessageBlock { + uint64_t receiveTime; // milliseconds since epoch uint8_t nextFragmentNum; };