From: David Goulet Date: Tue, 16 Oct 2012 18:21:29 +0000 (-0400) Subject: Fix: Empty metadata buffer(s) on HUP|ERR X-Git-Tag: v2.1.0-rc5~24 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4bb94b7597f56f5200ebd6a88e906488172241fb;p=lttng-tools.git Fix: Empty metadata buffer(s) on HUP|ERR The metadata fd was not emptying all the buffers on POLLHUP | POLLERR. This patch makes the read subbuffer operation, for hung up metadata fd, loop until the returned len is a negative value. For user space tracing, -EAGAIN is returned and -ENODATA for the kernel tracer. We also fixes another issue where an error returned (not -EAGAIN) by the read subbuffer function call was stopping the thread. Now, the fd is removed from the poll set, the stream is freed and the thread continues. Fixes #378 Signed-off-by: David Goulet --- diff --git a/src/common/consumer.c b/src/common/consumer.c index 242b05b3d..8b43257bd 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1888,12 +1888,15 @@ restart: lttng_ustconsumer_on_stream_hangup(stream); /* We just flushed the stream now read it. */ - len = ctx->on_buffer_ready(stream, ctx); - /* It's ok to have an unavailable sub-buffer */ - if (len < 0 && len != -EAGAIN) { - rcu_read_unlock(); - goto end; - } + do { + len = ctx->on_buffer_ready(stream, ctx); + /* + * We don't check the return value here since if we get + * a negative len, it means an error occured thus we + * simply remove it from the poll set and free the + * stream. + */ + } while (len > 0); } lttng_poll_del(&events, stream->wait_fd);