Backport: trackers: update lttng-sessiond
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.c
index b86bdfe6060b37c0698f805f2daa89491d54101d..d1f826883538fe7c5cfeab19eefad1f5990cd400 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>
@@ -157,22 +156,44 @@ struct ltt_kernel_session *trace_kernel_create_session(void)
        lks->metadata = NULL;
        CDS_INIT_LIST_HEAD(&lks->channel_list.head);
 
+       lks->tracker_list_pid = lttng_tracker_list_create();
+       if (!lks->tracker_list_pid) {
+               goto error;
+       }
+       lks->tracker_list_vpid = lttng_tracker_list_create();
+       if (!lks->tracker_list_vpid) {
+               goto error;
+       }
+       lks->tracker_list_uid = lttng_tracker_list_create();
+       if (!lks->tracker_list_uid) {
+               goto error;
+       }
+       lks->tracker_list_vuid = lttng_tracker_list_create();
+       if (!lks->tracker_list_vuid) {
+               goto error;
+       }
+       lks->tracker_list_gid = lttng_tracker_list_create();
+       if (!lks->tracker_list_gid) {
+               goto error;
+       }
+       lks->tracker_list_vgid = lttng_tracker_list_create();
+       if (!lks->tracker_list_vgid) {
+               goto error;
+       }
        lks->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
        if (lks->consumer == NULL) {
                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:
+       lttng_tracker_list_destroy(lks->tracker_list_pid);
+       lttng_tracker_list_destroy(lks->tracker_list_vpid);
+       lttng_tracker_list_destroy(lks->tracker_list_uid);
+       lttng_tracker_list_destroy(lks->tracker_list_vuid);
+       lttng_tracker_list_destroy(lks->tracker_list_gid);
+       lttng_tracker_list_destroy(lks->tracker_list_vgid);
        free(lks);
 
 alloc_error:
@@ -249,11 +270,33 @@ struct ltt_kernel_context *trace_kernel_create_context(
        if (ctx) {
                memcpy(&kctx->ctx, ctx, sizeof(kctx->ctx));
        }
+error:
+       return kctx;
+}
+
+/*
+ * Allocate and init a kernel context object from an existing kernel context
+ * object.
+ *
+ * Return the allocated object or NULL on error.
+ */
+struct ltt_kernel_context *trace_kernel_copy_context(
+               struct ltt_kernel_context *kctx)
+{
+       struct ltt_kernel_context *kctx_copy;
 
-       CDS_INIT_LIST_HEAD(&kctx->list);
+       assert(kctx);
+       kctx_copy = zmalloc(sizeof(*kctx_copy));
+       if (!kctx_copy) {
+               PERROR("zmalloc ltt_kernel_context");
+               goto error;
+       }
+
+       memcpy(kctx_copy, kctx, sizeof(*kctx_copy));
+       memset(&kctx_copy->list, 0, sizeof(kctx_copy->list));
 
 error:
-       return kctx;
+       return kctx_copy;
 }
 
 /*
@@ -471,7 +514,9 @@ void trace_kernel_destroy_context(struct ltt_kernel_context *ctx)
 {
        assert(ctx);
 
-       cds_list_del(&ctx->list);
+       if (ctx->in_list) {
+               cds_list_del(&ctx->list);
+       }
        free(ctx);
 }
 
@@ -578,8 +623,14 @@ 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);
+
+       lttng_tracker_list_destroy(session->tracker_list_pid);
+       lttng_tracker_list_destroy(session->tracker_list_vpid);
+       lttng_tracker_list_destroy(session->tracker_list_uid);
+       lttng_tracker_list_destroy(session->tracker_list_vuid);
+       lttng_tracker_list_destroy(session->tracker_list_gid);
+       lttng_tracker_list_destroy(session->tracker_list_vgid);
 
        free(session);
 }
This page took 0.025012 seconds and 5 git commands to generate.