From 95ad024c3cf0835b65068563d506f87af884f8dc Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 29 Jan 2018 17:12:43 -0500 Subject: [PATCH] log: clear thread-local stream's ios flags on reuse when reusing a thread-local std::ostream for a new log entry, clear any ios flags (ie eofbit/failbit/badbit) that may have been set during its previous use without this, any stream errors (for example, passing a nullptr to operator<< sets the badbit) will result in all log output on that thread to be blank for the remainder of the process Signed-off-by: Casey Bodley --- src/common/CachedPrebufferedStreambuf.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common/CachedPrebufferedStreambuf.cc b/src/common/CachedPrebufferedStreambuf.cc index 1e27e1f5374ef..1675c0449a730 100644 --- a/src/common/CachedPrebufferedStreambuf.cc +++ b/src/common/CachedPrebufferedStreambuf.cc @@ -47,6 +47,8 @@ CachedPrebufferedStreambuf::create(prebuffered_data* data) streambuf = new CachedPrebufferedStreambuf(); } else { streambuf = t_os.streambuf; + // reset ios flags (failbit, badbit) from previous use + streambuf->get_ostream().clear(); } streambuf->data = data; streambuf->setp(data->m_buf, data->m_buf + data->m_buf_len); -- 2.39.5