Commit 52dca859 authored by Max Kellermann's avatar Max Kellermann

util/PeakBuffer: use IsEmpty() instead of IsNull()

The DynamicFifoBuffer methods never return nullptr when the buffer is empty or full; instead, they return an empty buffer. This bug caused an endless loop.
parent f5443163
......@@ -60,7 +60,7 @@ FullyBufferedSocket::Flush()
assert(IsDefined());
const auto data = output.Read();
if (data.IsNull()) {
if (data.IsEmpty()) {
IdleMonitor::Cancel();
CancelWrite();
return true;
......
......@@ -43,13 +43,13 @@ PeakBuffer::Read() const
{
if (normal_buffer != nullptr) {
const auto p = normal_buffer->Read();
if (!p.IsNull())
if (!p.IsEmpty())
return p.ToVoid();
}
if (peak_buffer != nullptr) {
const auto p = peak_buffer->Read();
if (!p.IsNull())
if (!p.IsEmpty())
return p.ToVoid();
}
......@@ -85,7 +85,7 @@ AppendTo(DynamicFifoBuffer<uint8_t> &buffer, const void *data, size_t length)
do {
const auto p = buffer.Write();
if (p.IsNull())
if (p.IsEmpty())
break;
const size_t nbytes = std::min(length, p.size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment