X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=8e074fd91b0dcbe829f8c053d32ac6e92766d32c;hp=363d010a1a2aed47213e51ae240ed3a00fd5d460;hb=645328ae989e5f50a3a49c1ac34b2fee287a3d7b;hpb=c455d428591ca798da9f1e7c2aeb7db348d74853 diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 363d010a1..8e074fd91 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -165,10 +165,10 @@ struct ltt_kernel_channel *trace_kernel_create_channel( lkc->stream_count = 0; lkc->event_count = 0; lkc->enabled = 1; - lkc->ctx = NULL; /* Init linked list */ CDS_INIT_LIST_HEAD(&lkc->events_list.head); CDS_INIT_LIST_HEAD(&lkc->stream_list.head); + CDS_INIT_LIST_HEAD(&lkc->ctx_list); return lkc; @@ -176,6 +176,30 @@ error: return NULL; } +/* + * Allocate and init a kernel context object. + * + * Return the allocated object or NULL on error. + */ +struct ltt_kernel_context *trace_kernel_create_context( + struct lttng_kernel_context *ctx) +{ + struct ltt_kernel_context *kctx; + + kctx = zmalloc(sizeof(*kctx)); + if (!kctx) { + PERROR("zmalloc kernel context"); + goto error; + } + + if (ctx) { + memcpy(&kctx->ctx, ctx, sizeof(kctx->ctx)); + } + +error: + return kctx; +} + /* * Allocate and initialize a kernel event. Set name and event type. * @@ -375,6 +399,17 @@ void trace_kernel_destroy_event(struct ltt_kernel_event *event) free(event); } +/* + * Cleanup kernel context structure. + */ +void trace_kernel_destroy_context(struct ltt_kernel_context *ctx) +{ + assert(ctx); + + cds_list_del(&ctx->list); + free(ctx); +} + /* * Cleanup kernel channel structure. */ @@ -382,6 +417,7 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) { struct ltt_kernel_stream *stream, *stmp; struct ltt_kernel_event *event, *etmp; + struct ltt_kernel_context *ctx, *ctmp; int ret; assert(channel); @@ -405,11 +441,15 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) trace_kernel_destroy_event(event); } + /* For each context in the channel list */ + cds_list_for_each_entry_safe(ctx, ctmp, &channel->ctx_list, list) { + trace_kernel_destroy_context(ctx); + } + /* Remove from channel list */ cds_list_del(&channel->list); free(channel->channel); - free(channel->ctx); free(channel); }