Browse Source

try to read message payload immediately after header

pull/2094/head
orignal 4 months ago
parent
commit
2f54d95187
  1. 20
      libi2pd_client/I2CP.cpp

20
libi2pd_client/I2CP.cpp

@ -338,7 +338,27 @@ namespace client @@ -338,7 +338,27 @@ namespace client
if (m_PayloadLen > 0)
{
if (m_PayloadLen <= I2CP_MAX_MESSAGE_LENGTH)
{
if (!m_Socket) return;
boost::system::error_code ec;
size_t moreBytes = m_Socket->available(ec);
if (!ec)
{
if (moreBytes >= m_PayloadLen)
{
// read and process payload immediately if available
moreBytes = boost::asio::read (*m_Socket, boost::asio::buffer(m_Payload, m_PayloadLen), boost::asio::transfer_all (), ec);
HandleReceivedPayload (ec, moreBytes);
}
else
ReceivePayload ();
}
else
{
LogPrint (eLogWarning, "I2CP: Socket error: ", ec.message ());
Terminate ();
}
}
else
{
LogPrint (eLogError, "I2CP: Unexpected payload length ", m_PayloadLen);

Loading…
Cancel
Save