X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-kernel.c;h=d6ee8e8afb23401b2420e430bdd892dd0acc714d;hp=33a9e7e5578daf8454e5ccc97bc3d97d85e7934f;hb=e9404c27e7cc9d841785e6c4292c1add19fbc1cc;hpb=00a620843422e5c972aee0ada2181b811fc81b92 diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 33a9e7e55..d6ee8e8af 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -15,7 +15,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -27,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. @@ -162,14 +163,6 @@ struct ltt_kernel_session *trace_kernel_create_session(void) goto error; } - /* - * The tmp_consumer stays NULL until a set_consumer_uri command is - * executed. At this point, the consumer should be nullify until an - * enable_consumer command. This assignment is symbolic since we've zmalloc - * the struct. - */ - lks->tmp_consumer = NULL; - return lks; error: @@ -188,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); @@ -200,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 @@ -227,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; } @@ -258,6 +265,7 @@ error: /* * Allocate and initialize a kernel event. Set name and event type. + * We own filter_expression, and filter. * * Return pointer to structure or NULL. */ @@ -327,6 +335,8 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev, return lke; error: + free(filter_expression); + free(filter); free(lke); free(attr); return NULL; @@ -481,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); @@ -511,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); } @@ -575,8 +591,7 @@ void trace_kernel_destroy_session(struct ltt_kernel_session *session) } /* Wipe consumer output object */ - consumer_destroy_output(session->consumer); - consumer_destroy_output(session->tmp_consumer); + consumer_output_put(session->consumer); free(session); }