mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
resend non-Acked packets together
This commit is contained in:
parent
053d1d22ac
commit
e09e3980c9
@ -431,6 +431,54 @@ namespace stream
|
||||
return false;
|
||||
}
|
||||
|
||||
void Stream::SendPackets (const std::vector<Packet *>& packets)
|
||||
{
|
||||
if (!m_RemoteLeaseSet)
|
||||
{
|
||||
UpdateCurrentRemoteLease ();
|
||||
if (!m_RemoteLeaseSet)
|
||||
{
|
||||
LogPrint ("Can't send packets. Missing remote LeaseSet");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
I2NPMessage * leaseSet = nullptr;
|
||||
if (m_LeaseSetUpdated)
|
||||
{
|
||||
leaseSet = m_LocalDestination->GetLeaseSetMsg ();
|
||||
m_LeaseSetUpdated = false;
|
||||
}
|
||||
|
||||
auto outboundTunnel = m_LocalDestination->GetTunnelPool ()->GetNextOutboundTunnel ();
|
||||
if (outboundTunnel)
|
||||
{
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
if (ts >= m_CurrentRemoteLease.endDate)
|
||||
UpdateCurrentRemoteLease ();
|
||||
if (ts < m_CurrentRemoteLease.endDate)
|
||||
{
|
||||
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||
for (auto it: packets)
|
||||
{
|
||||
auto msg = i2p::garlic::routing.WrapMessage (*m_RemoteLeaseSet,
|
||||
CreateDataMessage (this, it->GetBuffer (), it->GetLength ()), leaseSet);
|
||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||
{
|
||||
i2p::tunnel::eDeliveryTypeTunnel,
|
||||
m_CurrentRemoteLease.tunnelGateway, m_CurrentRemoteLease.tunnelID,
|
||||
msg
|
||||
});
|
||||
}
|
||||
outboundTunnel->SendTunnelDataMsg (msgs);
|
||||
}
|
||||
else
|
||||
LogPrint ("All leases are expired");
|
||||
}
|
||||
else
|
||||
LogPrint ("No outbound tunnels in the pool");
|
||||
}
|
||||
|
||||
void Stream::ScheduleResend ()
|
||||
{
|
||||
m_ResendTimer.cancel ();
|
||||
@ -443,17 +491,20 @@ namespace stream
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
std::vector<Packet *> packets;
|
||||
for (auto it : m_SentPackets)
|
||||
{
|
||||
it->numResendAttempts++;
|
||||
if (it->numResendAttempts <= MAX_NUM_RESEND_ATTEMPTS)
|
||||
SendPacket (it->GetBuffer (), it->GetLength ());
|
||||
packets.push_back (it);
|
||||
else
|
||||
{
|
||||
Close ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (packets.size () > 0)
|
||||
SendPackets (packets);
|
||||
ScheduleResend ();
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,8 @@ namespace stream
|
||||
|
||||
void SendQuickAck ();
|
||||
bool SendPacket (Packet * packet);
|
||||
bool SendPacket (const uint8_t * buf, size_t len);
|
||||
bool SendPacket (const uint8_t * buf, size_t len); // TODO: remove
|
||||
void SendPackets (const std::vector<Packet *>& packets);
|
||||
|
||||
void SavePacket (Packet * packet);
|
||||
void ProcessPacket (Packet * packet);
|
||||
|
Loading…
Reference in New Issue
Block a user