From: Mathieu Desnoyers Date: Wed, 27 Feb 2013 21:39:30 +0000 (-0500) Subject: Fix: don't flush-final for offset 0 if reader is on sub-buffer X-Git-Tag: v2.1.2~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7e21c569b172c3f2254c999061aa6395b05f875d;p=lttng-ust.git Fix: don't flush-final for offset 0 if reader is on sub-buffer Signed-off-by: Mathieu Desnoyers --- diff --git a/libringbuffer/ring_buffer_frontend.c b/libringbuffer/ring_buffer_frontend.c index d1704dbf..650affad 100644 --- a/libringbuffer/ring_buffer_frontend.c +++ b/libringbuffer/ring_buffer_frontend.c @@ -1209,6 +1209,19 @@ int lib_ring_buffer_try_switch_slow(enum switch_mode mode, */ if (mode == SWITCH_FLUSH || off > 0) { if (caa_unlikely(off == 0)) { + /* + * A final flush that encounters an empty + * sub-buffer cannot switch buffer if a + * reader is located within this sub-buffer. + * Anyway, the purpose of final flushing of a + * sub-buffer at offset 0 is to handle the case + * of entirely empty stream. + */ + if (caa_unlikely(subbuf_trunc(offsets->begin, chan) + - subbuf_trunc((unsigned long) + uatomic_read(&buf->consumed), chan) + >= chan->backend.buf_size)) + return -1; /* * The client does not save any header information. * Don't switch empty subbuffer on finalize, because it