Commit 3e4e6f7c authored by Max Kellermann's avatar Max Kellermann

input/nfs: never read more than space available in buffer

Avoids off-by-one bug and obsoletes the bug fix in commit 966c4244
parent 936eb43c
...@@ -93,12 +93,14 @@ NfsInputStream::DoRead() ...@@ -93,12 +93,14 @@ NfsInputStream::DoRead()
if (remaining <= 0) if (remaining <= 0)
return true; return true;
if (IsBufferFull()) { const size_t buffer_space = GetBufferSpace();
if (buffer_space == 0) {
Pause(); Pause();
return true; return true;
} }
size_t nbytes = std::min<uint64_t>(remaining, 32768); size_t nbytes = std::min<size_t>(std::min<uint64_t>(remaining, 32768),
buffer_space);
mutex.unlock(); mutex.unlock();
Error error; Error error;
......
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