|
|
@ -488,6 +488,9 @@ namespace transport |
|
|
|
m_ReceiveBufferOffset += bytes_transferred; |
|
|
|
m_ReceiveBufferOffset += bytes_transferred; |
|
|
|
|
|
|
|
|
|
|
|
if (m_ReceiveBufferOffset >= 16) |
|
|
|
if (m_ReceiveBufferOffset >= 16) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int numReloads = 0; |
|
|
|
|
|
|
|
do |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t * nextBlock = m_ReceiveBuffer; |
|
|
|
uint8_t * nextBlock = m_ReceiveBuffer; |
|
|
|
while (m_ReceiveBufferOffset >= 16) |
|
|
|
while (m_ReceiveBufferOffset >= 16) |
|
|
@ -502,6 +505,32 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_ReceiveBufferOffset > 0) |
|
|
|
if (m_ReceiveBufferOffset > 0) |
|
|
|
memcpy (m_ReceiveBuffer, nextBlock, m_ReceiveBufferOffset); |
|
|
|
memcpy (m_ReceiveBuffer, nextBlock, m_ReceiveBufferOffset); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try to read more
|
|
|
|
|
|
|
|
if (numReloads < 5) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
boost::asio::socket_base::bytes_readable command (true); |
|
|
|
|
|
|
|
m_Socket.io_control (command); |
|
|
|
|
|
|
|
size_t moreBytes = command.get(); |
|
|
|
|
|
|
|
if (moreBytes) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (moreBytes > NTCP_BUFFER_SIZE - m_ReceiveBufferOffset) |
|
|
|
|
|
|
|
moreBytes = NTCP_BUFFER_SIZE - m_ReceiveBufferOffset; |
|
|
|
|
|
|
|
boost::system::error_code ec; |
|
|
|
|
|
|
|
moreBytes = m_Socket.read_some (boost::asio::buffer (m_ReceiveBuffer + m_ReceiveBufferOffset, moreBytes)); |
|
|
|
|
|
|
|
if (ec) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "Read more bytes error: ", ec.message ()); |
|
|
|
|
|
|
|
Terminate (); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m_NumReceivedBytes += moreBytes; |
|
|
|
|
|
|
|
m_ReceiveBufferOffset += moreBytes; |
|
|
|
|
|
|
|
numReloads++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
while (m_ReceiveBufferOffset >= 16); |
|
|
|
m_Handler.Flush (); |
|
|
|
m_Handler.Flush (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|