From: Jérémie Galarneau Date: Mon, 10 Mar 2014 18:11:07 +0000 (-0400) Subject: Fix: Report errors occuring in lttng_live_read X-Git-Tag: v1.2.2~13 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=2875672988a4ff834617379e222a3c109fb5d903 Fix: Report errors occuring in lttng_live_read The lttng-live plugin does not return an error code when trying to open a live trace that is already opened by another client. Signed-off-by: Jérémie Galarneau --- diff --git a/converter/babeltrace.c b/converter/babeltrace.c index c53c4800..0ceca0c4 100644 --- a/converter/babeltrace.c +++ b/converter/babeltrace.c @@ -509,8 +509,6 @@ int bt_context_add_traces_recursive(struct bt_context *ctx, const char *path, if (ret < 0) { fprintf(stderr, "[warning] [Context] cannot open trace \"%s\" " "for reading.\n", path); - /* Allow to skip erroneous traces. */ - ret = 1; /* partial error */ } return ret; } diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index e3cab914..960c2240 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -1429,9 +1429,10 @@ error: return -1; } -void lttng_live_read(struct lttng_live_ctx *ctx) +int lttng_live_read(struct lttng_live_ctx *ctx) { - int ret, i; + int ret = -1; + int i; struct bt_ctf_iter *iter; const struct bt_ctf_event *event; struct bt_iter_pos begin_pos; @@ -1489,12 +1490,14 @@ void lttng_live_read(struct lttng_live_ctx *ctx) int flags; if (lttng_live_should_quit()) { + ret = 0; goto end_free; } while (!ctx->session->stream_count) { if (lttng_live_should_quit() || ctx->session_ids->len == 0) { + ret = 0; goto end_free; } ret = ask_new_streams(ctx); @@ -1517,6 +1520,7 @@ void lttng_live_read(struct lttng_live_ctx *ctx) } for (;;) { if (lttng_live_should_quit()) { + ret = 0; goto end_free; } event = bt_ctf_iter_read_event_flags(iter, &flags); @@ -1547,5 +1551,5 @@ void lttng_live_read(struct lttng_live_ctx *ctx) end_free: bt_context_put(ctx->bt_ctx); end: - return; + return ret; } diff --git a/formats/lttng-live/lttng-live-plugin.c b/formats/lttng-live/lttng-live-plugin.c index a8cae580..d7ea14a0 100644 --- a/formats/lttng-live/lttng-live-plugin.c +++ b/formats/lttng-live/lttng-live-plugin.c @@ -230,7 +230,7 @@ static int lttng_live_open_trace_read(const char *path) } if (ctx->session_ids->len > 0) { - lttng_live_read(ctx); + ret = lttng_live_read(ctx); } end_free: @@ -268,7 +268,9 @@ struct bt_trace_descriptor *lttng_live_open_trace(const char *path, int flags, pos->parent.rw_table = NULL; pos->parent.event_cb = NULL; pos->parent.trace = &pos->trace_descriptor; - lttng_live_open_trace_read(path); + if (lttng_live_open_trace_read(path) < 0) { + goto error; + } return &pos->trace_descriptor; error: diff --git a/formats/lttng-live/lttng-live.h b/formats/lttng-live/lttng-live.h index ae04e897..cf47437b 100644 --- a/formats/lttng-live/lttng-live.h +++ b/formats/lttng-live/lttng-live.h @@ -85,7 +85,7 @@ int lttng_live_connect_viewer(struct lttng_live_ctx *ctx); int lttng_live_establish_connection(struct lttng_live_ctx *ctx); int lttng_live_list_sessions(struct lttng_live_ctx *ctx, const char *path); int lttng_live_attach_session(struct lttng_live_ctx *ctx, uint64_t id); -void lttng_live_read(struct lttng_live_ctx *ctx); +int lttng_live_read(struct lttng_live_ctx *ctx); int lttng_live_get_new_streams(struct lttng_live_ctx *ctx, uint64_t id); int lttng_live_should_quit(void);