mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
move unsent I2NP messages to new session if replaced
This commit is contained in:
parent
4100249313
commit
a1322d4667
3 changed files with 21 additions and 2 deletions
|
@ -313,6 +313,7 @@ namespace transport
|
|||
m_SentHandshakePacket.reset (nullptr);
|
||||
m_ConnectTimer.cancel ();
|
||||
SetTerminationTimeout (SSU2_TERMINATION_TIMEOUT);
|
||||
SendQueue ();
|
||||
transports.PeerConnected (shared_from_this ());
|
||||
if (m_OnEstablished)
|
||||
{
|
||||
|
@ -389,9 +390,24 @@ namespace transport
|
|||
SetSendQueueSize (m_SendQueue.size ());
|
||||
}
|
||||
|
||||
void SSU2Session::MoveSendQueue (std::shared_ptr<SSU2Session> other)
|
||||
{
|
||||
if (!other || m_SendQueue.empty ()) return;
|
||||
std::vector<std::shared_ptr<I2NPMessage> > msgs;
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
for (auto it: m_SendQueue)
|
||||
if (!it->IsExpired (ts))
|
||||
msgs.push_back (it);
|
||||
else
|
||||
it->Drop ();
|
||||
m_SendQueue.clear ();
|
||||
if (!msgs.empty ())
|
||||
other->PostI2NPMessages (msgs);
|
||||
}
|
||||
|
||||
bool SSU2Session::SendQueue ()
|
||||
{
|
||||
if (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize)
|
||||
if (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize && IsEstablished ())
|
||||
{
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
uint64_t mts = i2p::util::GetMonotonicMicroseconds ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue