io: Explicitly reset discard flag

When we discard output because there's been too much, we print a
warning, but subsequent uses of the same buffer still discard.

Now we explicitly reset the flag, so we warn once and everything works
normal after.

Fixes #5267.
This commit is contained in:
Fabian Homborg
2018-10-24 16:59:24 +02:00
parent 809998a9a5
commit c5d72332ba

View File

@@ -101,6 +101,10 @@ class separated_buffer_t {
discard = true;
}
void reset_discard() {
discard = false;
}
/// Serialize the contents to a single string, where explicitly separated elements have a
/// newline appended.
StringType newline_serialized() const {
@@ -228,7 +232,10 @@ class io_buffer_t : public io_pipe_t {
explicit io_buffer_t(int f, size_t limit)
: io_pipe_t(IO_BUFFER, f, false /* not input */),
buffer_(limit) {}
buffer_(limit) {
// Explicitly reset the discard flag because we share this buffer.
buffer_.reset_discard();
}
public:
void print() const override;