mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-27 13:14:15 +00:00
send packets of a longer message at the that time
This commit is contained in:
parent
68c321609d
commit
eb6b04d6c2
@ -246,6 +246,7 @@ namespace stream
|
|||||||
size_t Stream::Send (const uint8_t * buf, size_t len)
|
size_t Stream::Send (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
bool isNoAck = m_LastReceivedSequenceNumber < 0; // first packet
|
bool isNoAck = m_LastReceivedSequenceNumber < 0; // first packet
|
||||||
|
std::vector<Packet *> packets;
|
||||||
while (!m_IsOpen || len > 0)
|
while (!m_IsOpen || len > 0)
|
||||||
{
|
{
|
||||||
Packet * p = new Packet ();
|
Packet * p = new Packet ();
|
||||||
@ -309,9 +310,10 @@ namespace stream
|
|||||||
size += sentLen; // payload
|
size += sentLen; // payload
|
||||||
}
|
}
|
||||||
p->len = size;
|
p->len = size;
|
||||||
m_Service.post (std::bind (&Stream::SendPacket, this, p));
|
packets.push_back (p);
|
||||||
}
|
}
|
||||||
|
if (packets.size () > 0)
|
||||||
|
m_Service.post (std::bind (&Stream::PostPackets, this, packets));
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +422,31 @@ namespace stream
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stream::PostPackets (const std::vector<Packet *> packets)
|
||||||
|
{
|
||||||
|
if (m_IsOpen)
|
||||||
|
{
|
||||||
|
if (packets.size () > 0)
|
||||||
|
{
|
||||||
|
m_IsAckSendScheduled = false;
|
||||||
|
m_AckSendTimer.cancel ();
|
||||||
|
}
|
||||||
|
bool isEmpty = m_SentPackets.empty ();
|
||||||
|
for (auto it: packets)
|
||||||
|
m_SentPackets.insert (it);
|
||||||
|
SendPackets (packets);
|
||||||
|
if (isEmpty)
|
||||||
|
ScheduleResend ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// delete
|
||||||
|
for (auto it: packets)
|
||||||
|
delete it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Stream::SendPackets (const std::vector<Packet *>& packets)
|
void Stream::SendPackets (const std::vector<Packet *>& packets)
|
||||||
{
|
{
|
||||||
if (!m_RemoteLeaseSet)
|
if (!m_RemoteLeaseSet)
|
||||||
|
@ -112,6 +112,7 @@ namespace stream
|
|||||||
|
|
||||||
void SendQuickAck ();
|
void SendQuickAck ();
|
||||||
bool SendPacket (Packet * packet);
|
bool SendPacket (Packet * packet);
|
||||||
|
void PostPackets (const std::vector<Packet *> packets);
|
||||||
void SendPackets (const std::vector<Packet *>& packets);
|
void SendPackets (const std::vector<Packet *>& packets);
|
||||||
|
|
||||||
void SavePacket (Packet * packet);
|
void SavePacket (Packet * packet);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user