mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 11:30:36 +00:00
iostream: extend eof condition to read_exactly users as well
We currently only signal eof for consume() users. If one is calling read_exactly, eof will never be signalled. This might make some sense in continuous streams, but specially when dealing with files, eof is a natural part of line that can and will happen all the time. Every "read-until-finish" file-loop will at some point rely on eof. Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
This commit is contained in:
committed by
Avi Kivity
parent
5bc8d7cfad
commit
eb384236fd
@@ -81,6 +81,7 @@ input_stream<CharType>::read_exactly_part(size_t n, tmp_buf out, size_t complete
|
||||
// _buf is now empty
|
||||
return _fd.get().then([this, n, out = std::move(out), completed] (auto buf) mutable {
|
||||
if (buf.size() == 0) {
|
||||
_eof = true;
|
||||
return make_ready_future<tmp_buf>(std::move(buf));
|
||||
}
|
||||
_buf = std::move(buf);
|
||||
@@ -103,6 +104,7 @@ input_stream<CharType>::read_exactly(size_t n) {
|
||||
// buffer is empty: grab one and retry
|
||||
return _fd.get().then([this, n] (auto buf) mutable {
|
||||
if (buf.size() == 0) {
|
||||
_eof = true;
|
||||
return make_ready_future<tmp_buf>(std::move(buf));
|
||||
}
|
||||
_buf = std::move(buf);
|
||||
|
||||
Reference in New Issue
Block a user