Merge tag 'v0.23.17'
release v0.23.17
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user