Merge tag 'v0.23.17'

release v0.23.17
This commit is contained in:
Max Kellermann
2025-01-29 17:18:28 +01:00
7 changed files with 66 additions and 8 deletions

View File

@@ -171,9 +171,12 @@ AsyncInputStream::Read(std::unique_lock<Mutex> &lock,
Check();
r = buffer.Read();
if (!r.empty() || IsEOF())
if (!r.empty())
break;
if (IsEOF())
return 0;
caller_cond.wait(lock);
}
@@ -181,6 +184,12 @@ AsyncInputStream::Read(std::unique_lock<Mutex> &lock,
memcpy(dest.data(), r.data(), nbytes);
buffer.Consume(nbytes);
if (buffer.empty())
/* when the buffer becomes empty, reset its head and
tail so the next write can fill the whole buffer
and not just the part after the tail */
buffer.Clear();
offset += (offset_type)nbytes;
if (paused && buffer.GetSize() < resume_at)

View File

@@ -169,6 +169,14 @@ ThreadInputStream::Read(std::unique_lock<Mutex> &lock,
size_t nbytes = std::min(dest.size(), r.size());
memcpy(dest.data(), r.data(), nbytes);
buffer.Consume(nbytes);
if (buffer.empty())
/* when the buffer becomes empty,
reset its head and tail so the next
write can fill the whole buffer and
not just the part after the tail */
buffer.Clear();
wake_cond.notify_one();
offset += nbytes;
return nbytes;