From: David Goulet Date: Wed, 5 Oct 2011 22:09:23 +0000 (-0400) Subject: Fix bad channel handling on enable-event X-Git-Tag: v2.0-pre15~192 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f6cd6b0faf5227d5b4a191ef7e6be84047be9bbd;p=lttng-tools.git Fix bad channel handling on enable-event The channel attributes and name were not passed to the create function when a channel is requested and did not exist on enable-event. Signed-off-by: David Goulet --- diff --git a/ltt-sessiond/channel.c b/ltt-sessiond/channel.c index 350bab6ab..10635536c 100644 --- a/ltt-sessiond/channel.c +++ b/ltt-sessiond/channel.c @@ -30,7 +30,7 @@ /* * Return allocated channel attributes. */ -static struct lttng_channel *init_default_attr(int dom) +struct lttng_channel *channel_new_default_attr(int dom) { struct lttng_channel *chan; @@ -164,7 +164,7 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, /* Creating channel attributes if needed */ if (attr == NULL) { - attr = init_default_attr(LTTNG_DOMAIN_KERNEL); + attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL); if (attr == NULL) { ret = LTTCOMM_FATAL; goto error; @@ -202,7 +202,7 @@ int channel_ust_create(struct ltt_ust_session *usession, /* Creating channel attributes if needed */ if (attr == NULL) { - attr = init_default_attr(LTTNG_DOMAIN_UST_PID); + attr = channel_new_default_attr(LTTNG_DOMAIN_UST_PID); if (attr == NULL) { ret = LTTCOMM_FATAL; goto error; diff --git a/ltt-sessiond/channel.h b/ltt-sessiond/channel.h index 4c368e619..dfde76994 100644 --- a/ltt-sessiond/channel.h +++ b/ltt-sessiond/channel.h @@ -39,4 +39,6 @@ int channel_ust_disable(struct ltt_ust_session *usession, int channel_ust_enable(struct ltt_ust_session *usession, struct ltt_ust_channel *uchan, int sock); +struct lttng_channel *channel_new_default_attr(int domain); + #endif /* _LTT_CHANNEL_H */ diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 8c09339ab..f887fa124 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -2053,15 +2053,23 @@ static int cmd_enable_event(struct ltt_session *session, int domain, { int ret; struct ltt_kernel_channel *kchan; + struct lttng_channel *attr; switch (domain) { case LTTNG_DOMAIN_KERNEL: kchan = trace_kernel_get_channel_by_name(channel_name, session->kernel_session); if (kchan == NULL) { + attr = channel_new_default_attr(domain); + if (attr == NULL) { + ret = LTTCOMM_FATAL; + goto error; + } + snprintf(attr->name, NAME_MAX, "%s", channel_name); + /* This call will notify the kernel thread */ ret = channel_kernel_create(session->kernel_session, - NULL, kernel_poll_pipe[1]); + attr, kernel_poll_pipe[1]); if (ret != LTTCOMM_OK) { goto error; }