X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Flttng-live%2Flttng-live-comm.c;h=e08926380efab45e306a01ec59607012f51fbc90;hp=b61371fc5dba65523eb46f5f1e69b391d2103990;hb=1e8e8e2fb8ef9e36cbc2c5a692e9fa1d11cbb52a;hpb=4a6f6ed3aeb9845dec4b8ec9ca8573ed1c064187 diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index b61371fc..e0892638 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -1499,6 +1499,12 @@ int add_one_trace(struct lttng_live_ctx *ctx, ret = 0; goto end; } + /* + * add_one_trace can be called recursively if during the + * bt_context_add_trace call we need to fetch new streams, so we need to + * prevent a recursive call to process our current trace. + */ + trace->in_use = 1; BT_INIT_LIST_HEAD(&mmap_list.head); @@ -1561,7 +1567,6 @@ int add_one_trace(struct lttng_live_ctx *ctx, } trace->trace_id = ret; - trace->in_use = 1; printf_verbose("Trace now in use, id = %d\n", trace->trace_id); goto end; @@ -1630,9 +1635,13 @@ int add_traces(struct lttng_live_ctx *ctx) GHashTableIter it; gpointer key; gpointer value; + unsigned int nr_traces; printf_verbose("Begin add traces\n"); +retry: + nr_traces = g_hash_table_size(ctx->session->ctf_traces); + ret = check_traces_metadata(ctx); if (ret < 0) { goto end; @@ -1645,6 +1654,15 @@ int add_traces(struct lttng_live_ctx *ctx) if (ret < 0) { goto end; } + /* + * If a new trace got added while we were adding the trace, the + * iterator is invalid and we have to restart. + */ + if (g_hash_table_size(ctx->session->ctf_traces) != nr_traces) { + printf_verbose("New trace(s) added during add_one_trace()\n"); + printf_verbose("JORAJ: GREP HERE\n"); + goto retry; + } } ret = 0;