*
* @param newSize The minimum new size of the FIFO buffer.
*/
-void FIFO::ResizeBuffer(size_t newSize)
+void FIFO::ResizeBuffer(size_t newSize, bool decrease)
{
- if (m_AllocSize >= newSize)
+ if (m_AllocSize >= newSize && !decrease)
return;
newSize = (newSize / FIFO::BlockSize + 1) * FIFO::BlockSize;
+ if (newSize == m_AllocSize)
+ return;
+
char *newBuffer = static_cast<char *>(realloc(m_Buffer, newSize));
if (newBuffer == NULL)
memcpy(m_Buffer, m_Buffer + m_Offset, m_DataSize);
m_Offset = 0;
- ResizeBuffer(m_DataSize);
+ if (m_DataSize > 0)
+ ResizeBuffer(m_DataSize, true);
return;
}
*/
void FIFO::Write(const void *buffer, size_t count)
{
- ResizeBuffer(m_Offset + m_DataSize + count);
+ ResizeBuffer(m_Offset + m_DataSize + count, false);
memcpy(m_Buffer + m_Offset + m_DataSize, buffer, count);
m_DataSize += count;
}
} catch (const std::exception& ex) {
Log(LogWarning, "jsonrpc", "Error while reading JSON-RPC message for endpoint '" + GetName() + "': " + boost::diagnostic_information(ex));
- GetClient()->Close();
-
m_Client.reset();
}
if (!endpoint)
endpoint = Endpoint::MakeEndpoint(identity, true);
- BufferedStream::Ptr bufferedStream = boost::make_shared<BufferedStream>(tlsStream);
-
- endpoint->SetClient(bufferedStream);
+ endpoint->SetClient(tlsStream);
}
/**