From e29395a8120118fa59d3e464442135b0b1940fc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 10 Mar 2014 18:03:24 -0400 Subject: [PATCH 1/1] Fix: Add missing lttng_live_should_quit checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Missing should_quit checks can cause the live plugin to report errors on exit. Signed-off-by: Jérémie Galarneau --- formats/lttng-live/lttng-live-comm.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index 960c2240..9feb7185 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -544,6 +544,9 @@ restart: printf_verbose("Asking for new streams returns %d\n", ret); if (ret < 0) { + if (lttng_live_should_quit()) { + goto end; + } if (ret == -LTTNG_VIEWER_NEW_STREAMS_HUP) { printf_verbose("Session %" PRIu64 " closed\n", id); @@ -1065,7 +1068,9 @@ retry: ret = get_next_index(session->ctx, viewer_stream, cur_index); if (ret < 0) { pos->offset = EOF; - fprintf(stderr, "[error] get_next_index failed\n"); + if (!lttng_live_should_quit()) { + fprintf(stderr, "[error] get_next_index failed\n"); + } return; } @@ -1115,7 +1120,9 @@ retry: goto retry; } else if (ret < 0) { pos->offset = EOF; - fprintf(stderr, "[error] get_data_packet failed\n"); + if (!lttng_live_should_quit()) { + fprintf(stderr, "[error] get_data_packet failed\n"); + } return; } @@ -1515,6 +1522,10 @@ int lttng_live_read(struct lttng_live_ctx *ctx) begin_pos.type = BT_SEEK_BEGIN; iter = bt_ctf_iter_create(ctx->bt_ctx, &begin_pos, NULL); if (!iter) { + if (lttng_live_should_quit()) { + ret = 0; + goto end; + } fprintf(stderr, "[error] Iterator creation error\n"); goto end; } @@ -1551,5 +1562,8 @@ int lttng_live_read(struct lttng_live_ctx *ctx) end_free: bt_context_put(ctx->bt_ctx); end: + if (lttng_live_should_quit()) { + ret = 0; + } return ret; } -- 2.34.1