]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
log: clear thread-local stream's ios flags on reuse 20174/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 29 Jan 2018 22:12:43 +0000 (17:12 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 30 Jan 2018 14:28:01 +0000 (09:28 -0500)
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 <cbodley@redhat.com>
src/common/CachedPrebufferedStreambuf.cc

index 1e27e1f5374ef5be562fa1634564584a4ee44af1..1675c0449a730c7d27c04be05d7182d7b289630e 100644 (file)
@@ -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);