X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel.c;h=b417cb07759c4f30795b9240508b31e2148ffd77;hp=bf03dbad985388a2355dcb2a46b3ad7281c9fccf;hb=5922e6c21e0ad1a5050b2440bcc14f15abd9c5f4;hpb=536322299f7fc9ef136a0d7e50ba8e1b5d7a754b diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index bf03dbad9..b417cb077 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -66,35 +66,6 @@ error: return ret; } -/* - * Add context on a kernel event. - */ -int kernel_add_event_context(struct ltt_kernel_event *event, - struct lttng_kernel_context *ctx) -{ - int ret; - - DBG("Adding context to event %s", event->event->name); - ret = kernctl_add_context(event->fd, ctx); - if (ret < 0) { - PERROR("add context ioctl"); - goto error; - } - - event->ctx = zmalloc(sizeof(struct lttng_kernel_context)); - if (event->ctx == NULL) { - PERROR("zmalloc event context"); - goto error; - } - - memcpy(event->ctx, ctx, sizeof(struct lttng_kernel_context)); - - return 0; - -error: - return ret; -} - /* * Create a new kernel session, register it to the kernel tracer and add it to * the session daemon session. @@ -177,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); @@ -585,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; @@ -613,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; @@ -738,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--; + } +}