local sync: fixed a bug when overflowing the default message size

The code which resized the buffer for inter-process communication
forgot to update the buffer size, leading to a recv() with zero
size, leading to an error ("Operation not supported") and an aborted
sync.
This commit is contained in:
Patrick Ohly 2010-12-07 18:21:40 +01:00
parent 4ef72084a0
commit d3284d72a8
2 changed files with 14 additions and 4 deletions

View File

@ -341,6 +341,18 @@ void LocalTransportAgent::checkChildReport()
}
}
bool LocalTransportAgent::Buffer::haveMessage()
{
bool complete = m_used >= sizeof(Message) &&
m_message->m_length <= m_used;
SE_LOG_DEBUG(NULL, NULL, "message of size %ld/%ld/%ld, %s",
(long)m_used,
m_used < sizeof(Message) ? -1l : (long)m_message->m_length,
(long)m_size,
complete ? "complete" : "incomplete");
return complete;
}
void LocalTransportAgent::send(const char *data, size_t len)
{
if (m_loop) {
@ -470,6 +482,7 @@ void LocalTransportAgent::readMessage(int fd, Buffer &buffer)
buffer.m_message->m_length > buffer.m_size) {
buffer.m_message.set(static_cast<Message *>(realloc(buffer.m_message.release(), buffer.m_message->m_length)),
"Message Buffer");
buffer.m_size = buffer.m_message->m_length;
}
SE_LOG_DEBUG(NULL, NULL, "%s: recv %ld bytes",
m_pid ? "parent" : "child",

View File

@ -138,10 +138,7 @@ class LocalTransportAgent : public TransportAgent
/** number of valid bytes in buffer */
size_t m_used;
bool haveMessage() {
return m_used >= sizeof(Message) &&
m_message->m_length <= m_used;
}
bool haveMessage();
} m_receiveBuffer;
/**