Browse Source

clean up incomplete messages

pull/734/head
orignal 8 years ago
parent
commit
381f6b184e
  1. 9
      TunnelEndpoint.cpp
  2. 1
      TunnelEndpoint.h

9
TunnelEndpoint.cpp

@ -116,6 +116,7 @@ namespace tunnel
if (!isFollowOnFragment) // create new incomlete message if (!isFollowOnFragment) // create new incomlete message
{ {
m.nextFragmentNum = 1; m.nextFragmentNum = 1;
m.receiveTime = i2p::util::GetMillisecondsSinceEpoch ();
auto ret = m_IncompleteMessages.insert (std::pair<uint32_t, TunnelMessageBlockEx>(msgID, m)); auto ret = m_IncompleteMessages.insert (std::pair<uint32_t, TunnelMessageBlockEx>(msgID, m));
if (ret.second) if (ret.second)
HandleOutOfSequenceFragments (msgID, ret.first->second); HandleOutOfSequenceFragments (msgID, ret.first->second);
@ -284,6 +285,14 @@ namespace tunnel
else else
++it; ++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;
}
} }
} }
} }

1
TunnelEndpoint.h

@ -15,6 +15,7 @@ namespace tunnel
{ {
struct TunnelMessageBlockEx: public TunnelMessageBlock struct TunnelMessageBlockEx: public TunnelMessageBlock
{ {
uint64_t receiveTime; // milliseconds since epoch
uint8_t nextFragmentNum; uint8_t nextFragmentNum;
}; };

Loading…
Cancel
Save