Implement consumer ring buffer position sampling
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.c
index b86bdfe6060b37c0698f805f2daa89491d54101d..d6ee8e8afb23401b2420e430bdd892dd0acc714d 100644 (file)
@@ -15,7 +15,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -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;
 }
 
@@ -484,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);
 
@@ -514,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);
 }
@@ -578,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);
 }
This page took 0.025571 seconds and 5 git commands to generate.