Fix: change function name for better meaning
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index 00172e80170c3089a9160bcd49ce8d72357107c0..b417cb07759c4f30795b9240508b31e2148ffd77 100644 (file)
@@ -148,6 +148,7 @@ int kernel_create_channel(struct ltt_kernel_session *session,
        /* Add channel to session */
        cds_list_add(&lkc->list, &session->channel_list.head);
        session->channel_count++;
+       lkc->session = session;
 
        DBG("Kernel channel %s created (fd: %d)", lkc->channel->name, lkc->fd);
 
@@ -556,7 +557,6 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
        int fd, pos, ret;
        char *event;
        size_t nbmem, count = 0;
-       ssize_t size;
        FILE *fp;
        struct lttng_event *elist;
 
@@ -584,7 +584,7 @@ ssize_t kernel_list_events(int tracer_fd, struct lttng_event **events)
                goto end;
        }
 
-       while ((size = fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos)) == 1) {
+       while (fscanf(fp, "event { name = %m[^;]; };%n\n", &event, &pos) == 1) {
                if (count >= nbmem) {
                        struct lttng_event *new_elist;
 
@@ -709,3 +709,33 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess)
 
        trace_kernel_destroy_session(ksess);
 }
+
+/*
+ * Destroy a kernel channel object. It does not do anything on the tracer side.
+ */
+void kernel_destroy_channel(struct ltt_kernel_channel *kchan)
+{
+       struct ltt_kernel_session *ksess = NULL;
+
+       assert(kchan);
+       assert(kchan->channel);
+
+       DBG3("Kernel destroy channel %s", kchan->channel->name);
+
+       /* Update channel count of associated session. */
+       if (kchan->session) {
+               /* Keep pointer reference so we can update it after the destroy. */
+               ksess = kchan->session;
+       }
+
+       trace_kernel_destroy_channel(kchan);
+
+       /*
+        * At this point the kernel channel is not visible anymore. This is safe
+        * since in order to work on a visible kernel session, the tracing session
+        * lock (ltt_session.lock) MUST be acquired.
+        */
+       if (ksess) {
+               ksess->channel_count--;
+       }
+}
This page took 0.02341 seconds and 4 git commands to generate.