X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=d6ee8e8afb23401b2420e430bdd892dd0acc714d;hp=29432de49a0355b16863ab69189929a6c37719f3;hb=e9404c27e7cc9d841785e6c4292c1add19fbc1cc;hpb=40d253abbf635c6cf0b938298d56747cf67c11db;ds=sidebyside diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 29432de49..d6ee8e8af 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -26,6 +26,8 @@ #include "consumer.h" #include "trace-kernel.h" +#include "lttng-sessiond.h" +#include "notification-thread-commands.h" /* * Find the channel name for the given kernel session. @@ -179,6 +181,7 @@ struct ltt_kernel_channel *trace_kernel_create_channel( struct lttng_channel *chan) { struct ltt_kernel_channel *lkc; + struct lttng_channel_extended *extended; assert(chan); @@ -191,10 +194,18 @@ struct ltt_kernel_channel *trace_kernel_create_channel( lkc->channel = zmalloc(sizeof(struct lttng_channel)); if (lkc->channel == NULL) { PERROR("lttng_channel zmalloc"); - free(lkc); + goto error; + } + + extended = zmalloc(sizeof(struct lttng_channel_extended)); + if (!extended) { + PERROR("lttng_channel_channel zmalloc"); goto error; } memcpy(lkc->channel, chan, sizeof(struct lttng_channel)); + memcpy(extended, chan->attr.extended.ptr, sizeof(struct lttng_channel_extended)); + lkc->channel->attr.extended.ptr = extended; + extended = NULL; /* * If we receive an empty string for channel name, it means the @@ -218,6 +229,11 @@ struct ltt_kernel_channel *trace_kernel_create_channel( return lkc; error: + if (lkc) { + free(lkc->channel); + } + free(extended); + free(lkc); return NULL; } @@ -475,6 +491,7 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) struct ltt_kernel_event *event, *etmp; struct ltt_kernel_context *ctx, *ctmp; int ret; + enum lttng_error_code status; assert(channel); @@ -505,6 +522,11 @@ void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel) /* Remove from channel list */ cds_list_del(&channel->list); + status = notification_thread_command_remove_channel( + notification_thread_handle, + channel->fd, LTTNG_DOMAIN_KERNEL); + assert(status == LTTNG_OK); + free(channel->channel->attr.extended.ptr); free(channel->channel); free(channel); }