From: Casey Bodley Date: Mon, 29 Jan 2018 22:12:43 +0000 (-0500) Subject: log: clear thread-local stream's ios flags on reuse X-Git-Tag: v13.0.2~391^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F20174%2Fhead;p=ceph.git 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 --- diff --git a/src/common/CachedPrebufferedStreambuf.cc b/src/common/CachedPrebufferedStreambuf.cc index 1e27e1f5374e..1675c0449a73 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);