Browse Source

merge incomplete DATAGRAM SEND message

pull/170/head
orignal 10 years ago
parent
commit
8c174cd548
  1. 14
      SAM.cpp

14
SAM.cpp

@ -220,7 +220,8 @@ namespace client
if (processed < bytes_transferred) if (processed < bytes_transferred)
{ {
m_BufferOffset = bytes_transferred - processed; m_BufferOffset = bytes_transferred - processed;
memmove (m_Buffer, m_Buffer + processed, m_BufferOffset); if (processed > 0)
memmove (m_Buffer, m_Buffer + processed, m_BufferOffset);
} }
// since it's SAM v1 reply is not expected // since it's SAM v1 reply is not expected
Receive (); Receive ();
@ -420,7 +421,10 @@ namespace client
LogPrint (eLogError, "SAM session is not created from DATAGRAM SEND"); LogPrint (eLogError, "SAM session is not created from DATAGRAM SEND");
} }
else else
LogPrint (eLogError, "SAM sent datagram size ", size, " exceeds buffer"); {
LogPrint (eLogWarning, "SAM sent datagram size ", size, " exceeds buffer");
return 0; // try to receive more
}
return offset + size; return offset + size;
} }
@ -529,6 +533,12 @@ namespace client
void SAMSocket::Receive () void SAMSocket::Receive ()
{ {
if (m_BufferOffset >= SAM_SOCKET_BUFFER_SIZE)
{
LogPrint (eLogError, "Buffer is full. Terminate");
Terminate ();
return;
}
m_Socket.async_read_some (boost::asio::buffer(m_Buffer + m_BufferOffset, SAM_SOCKET_BUFFER_SIZE - m_BufferOffset), m_Socket.async_read_some (boost::asio::buffer(m_Buffer + m_BufferOffset, SAM_SOCKET_BUFFER_SIZE - m_BufferOffset),
std::bind((m_SocketType == eSAMSocketTypeStream) ? &SAMSocket::HandleReceived : &SAMSocket::HandleMessage, std::bind((m_SocketType == eSAMSocketTypeStream) ? &SAMSocket::HandleReceived : &SAMSocket::HandleMessage,
shared_from_this (), std::placeholders::_1, std::placeholders::_2)); shared_from_this (), std::placeholders::_1, std::placeholders::_2));

Loading…
Cancel
Save