Fix: Report errors occuring in lttng_live_read
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 10 Mar 2014 18:11:07 +0000 (14:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 10 Mar 2014 19:52:07 +0000 (15:52 -0400)
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 <jeremie.galarneau@efficios.com>
converter/babeltrace.c
formats/lttng-live/lttng-live-comm.c
formats/lttng-live/lttng-live-plugin.c
formats/lttng-live/lttng-live.h

index c53c4800046923a616ef9f6d583fd7753df7b692..0ceca0c40081ec9c4a721a47b59c33b2eb526ec7 100644 (file)
@@ -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;
        }
index e3cab91457fbf8ee2b6316a9bc4b31ad6143c7e6..960c2240129cba5115223816b2a09f1578c5dd95 100644 (file)
@@ -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;
 }
index a8cae580de7a140470fc78180db667839368f40e..d7ea14a07092ec06acb2c3ebedaa86996d56a1e9 100644 (file)
@@ -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:
index ae04e8979a18edd536e9bb5e3f7227322ccdee0a..cf47437bbd03e83f55331d2637833c987d1ae7ec 100644 (file)
@@ -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);
 
This page took 0.026429 seconds and 4 git commands to generate.