X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel.c;h=b417cb07759c4f30795b9240508b31e2148ffd77;hp=00172e80170c3089a9160bcd49ce8d72357107c0;hb=5922e6c21e0ad1a5050b2440bcc14f15abd9c5f4;hpb=601d5acf42ebdb05ff8aa19f12fd9bdad3602781 diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 00172e801..b417cb077 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -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--; + } +}