From eb384236fd1e7c92da333ef47e7161ee8d2f1b1a Mon Sep 17 00:00:00 2001 From: Glauber Costa Date: Fri, 27 Feb 2015 15:43:57 -0500 Subject: [PATCH] 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 --- core/iostream-impl.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iostream-impl.hh b/core/iostream-impl.hh index 6d62438d4f..09db41793e 100644 --- a/core/iostream-impl.hh +++ b/core/iostream-impl.hh @@ -81,6 +81,7 @@ input_stream::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(std::move(buf)); } _buf = std::move(buf); @@ -103,6 +104,7 @@ input_stream::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(std::move(buf)); } _buf = std::move(buf);