From c5d72332baee19a39d6a22d378babc5eef9c6c03 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 24 Oct 2018 16:59:24 +0200 Subject: [PATCH] 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. --- src/io.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/io.h b/src/io.h index 93ccab718..f6475d363 100644 --- a/src/io.h +++ b/src/io.h @@ -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;