mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
handle single packet
This commit is contained in:
parent
1e2a0a4549
commit
05946125b5
|
@ -1330,13 +1330,13 @@ namespace transport
|
||||||
{
|
{
|
||||||
i2p::transport::transports.UpdateReceivedBytes (bytes_transferred);
|
i2p::transport::transports.UpdateReceivedBytes (bytes_transferred);
|
||||||
packet->len = bytes_transferred;
|
packet->len = bytes_transferred;
|
||||||
std::vector<Packet *> packets;
|
|
||||||
packets.push_back (packet);
|
|
||||||
|
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
size_t moreBytes = socket.available (ec);
|
size_t moreBytes = socket.available (ec);
|
||||||
if (!ec)
|
if (!ec && moreBytes)
|
||||||
{
|
{
|
||||||
|
std::vector<Packet *> packets;
|
||||||
|
packets.push_back (packet);
|
||||||
while (moreBytes && packets.size () < 32)
|
while (moreBytes && packets.size () < 32)
|
||||||
{
|
{
|
||||||
packet = m_PacketsPool.AcquireMt ();
|
packet = m_PacketsPool.AcquireMt ();
|
||||||
|
@ -1355,9 +1355,10 @@ namespace transport
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GetService ().post (std::bind (&SSU2Server::HandleReceivedPackets, this, packets));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
GetService ().post (std::bind (&SSU2Server::HandleReceivedPacket, this, packets));
|
GetService ().post (std::bind (&SSU2Server::HandleReceivedPacket, this, packet));
|
||||||
Receive (socket);
|
Receive (socket);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1374,7 +1375,17 @@ namespace transport
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSU2Server::HandleReceivedPacket (std::vector<Packet *> packets)
|
void SSU2Server::HandleReceivedPacket (Packet * packet)
|
||||||
|
{
|
||||||
|
if (packet)
|
||||||
|
{
|
||||||
|
ProcessNextPacket (packet->buf, packet->len, packet->from);
|
||||||
|
m_PacketsPool.ReleaseMt (packet);
|
||||||
|
if (m_LastSession) m_LastSession->FlushData ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSU2Server::HandleReceivedPackets (std::vector<Packet *> packets)
|
||||||
{
|
{
|
||||||
for (auto& packet: packets)
|
for (auto& packet: packets)
|
||||||
ProcessNextPacket (packet->buf, packet->len, packet->from);
|
ProcessNextPacket (packet->buf, packet->len, packet->from);
|
||||||
|
|
|
@ -257,7 +257,8 @@ namespace transport
|
||||||
void Receive (boost::asio::ip::udp::socket& socket);
|
void Receive (boost::asio::ip::udp::socket& socket);
|
||||||
void HandleReceivedFrom (const boost::system::error_code& ecode, size_t bytes_transferred,
|
void HandleReceivedFrom (const boost::system::error_code& ecode, size_t bytes_transferred,
|
||||||
Packet * packet, boost::asio::ip::udp::socket& socket);
|
Packet * packet, boost::asio::ip::udp::socket& socket);
|
||||||
void HandleReceivedPacket (std::vector<Packet *> packets);
|
void HandleReceivedPacket (Packet * packet);
|
||||||
|
void HandleReceivedPackets (std::vector<Packet *> packets);
|
||||||
void ProcessNextPacket (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
void ProcessNextPacket (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
||||||
|
|
||||||
void ScheduleTermination ();
|
void ScheduleTermination ();
|
||||||
|
|
Loading…
Reference in a new issue