From 95681498599cbd3bc1aa6dfa725a668ab272170b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 5 Nov 2015 16:19:38 -0500 Subject: [PATCH] Fix: loading of live session within userspace domains MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The output of a session is session-specific and not bound to a domain. The "lttng_set_consumer_url" already acts on a session-wide basis. Fixes #973 Signed-off-by: Jérémie Galarneau --- include/lttng/domain.h | 1 + include/lttng/handle.h | 6 +++++- src/bin/lttng/commands/create.c | 11 ++++------- src/common/config/session-config.c | 28 ++++++++-------------------- src/lib/lttng-ctl/lttng-ctl.c | 10 ++++------ 5 files changed, 22 insertions(+), 34 deletions(-) diff --git a/include/lttng/domain.h b/include/lttng/domain.h index bff134a84..1e40b392a 100644 --- a/include/lttng/domain.h +++ b/include/lttng/domain.h @@ -28,6 +28,7 @@ extern "C" { * Domain types: the different possible tracers. */ enum lttng_domain_type { + LTTNG_DOMAIN_NONE = 0, /* No associated domain. */ LTTNG_DOMAIN_KERNEL = 1, /* Linux Kernel tracer. */ LTTNG_DOMAIN_UST = 2, /* Global Userspace tracer. */ LTTNG_DOMAIN_JUL = 3, /* Java Util Logging. */ diff --git a/include/lttng/handle.h b/include/lttng/handle.h index a313e7963..c5958b402 100644 --- a/include/lttng/handle.h +++ b/include/lttng/handle.h @@ -43,7 +43,11 @@ struct lttng_handle { * This handle contains the session name and domain on which the command will * be executed. A domain is basically a tracer like the kernel or user space. * - * Return an newly allocated handle that should be freed using + * A NULL domain indicates that the handle is not bound to a specific domain. + * This is mostly used for actions that apply on a session and not on a domain + * (e.g lttng_set_consumer_url). + * + * Return a newly allocated handle that should be freed using * lttng_destroy_handle. On error, NULL is returned. */ extern struct lttng_handle *lttng_create_handle(const char *session_name, diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 525464aa8..3379a3b27 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -141,18 +141,15 @@ static int set_consumer_url(const char *session_name, const char *ctrl_url, { int ret; struct lttng_handle *handle; - struct lttng_domain dom; assert(session_name); /* - * Set handle with the session name and the domain set to 0. This means to - * the session daemon that the next action applies on the tracing session - * rather then the domain specific session. + * Set handle with the session_name, but no domain. This implies that + * the actions taken with this handle apply on the tracing session + * rather then the domain-specific session. */ - memset(&dom, 0, sizeof(dom)); - - handle = lttng_create_handle(session_name, &dom); + handle = lttng_create_handle(session_name, NULL); if (handle == NULL) { ret = CMD_FATAL; goto error; diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index eea6c0a81..48094c59a 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -1151,17 +1151,16 @@ end: } static -int create_session_net_output(const char *name, struct lttng_domain *domain, - const char *control_uri, const char *data_uri) +int create_session_net_output(const char *name, const char *control_uri, + const char *data_uri) { int ret; struct lttng_handle *handle; const char *uri = NULL; assert(name); - assert(domain); - handle = lttng_create_handle(name, domain); + handle = lttng_create_handle(name, NULL); if (!handle) { ret = -LTTNG_ERR_NOMEM; goto end; @@ -1343,11 +1342,6 @@ int create_session(const char *name, } if (output.control_uri || output.data_uri) { - int i; - struct lttng_domain *domain; - struct lttng_domain *domains[] = - { kernel_domain, ust_domain, jul_domain, log4j_domain }; - /* network destination */ if (live_timer_interval && live_timer_interval != UINT64_MAX) { /* @@ -1363,18 +1357,12 @@ int create_session(const char *name, goto end; } - for (i = 0; i < (sizeof(domains) / sizeof(domains[0])); i++) { - domain = domains[i]; - if (!domain) { - continue; - } - - ret = create_session_net_output(name, domain, output.control_uri, - output.data_uri); - if (ret) { - goto end; - } + ret = create_session_net_output(name, output.control_uri, + output.data_uri); + if (ret) { + goto end; } + } else { /* either local output or no output */ ret = lttng_create_session(name, output.path); diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 4df1bdf3f..d0deade2e 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -519,10 +519,6 @@ struct lttng_handle *lttng_create_handle(const char *session_name, { struct lttng_handle *handle = NULL; - if (domain == NULL) { - goto end; - } - handle = zmalloc(sizeof(struct lttng_handle)); if (handle == NULL) { PERROR("malloc handle"); @@ -533,8 +529,10 @@ struct lttng_handle *lttng_create_handle(const char *session_name, lttng_ctl_copy_string(handle->session_name, session_name, sizeof(handle->session_name)); - /* Copy lttng domain */ - lttng_ctl_copy_lttng_domain(&handle->domain, domain); + /* Copy lttng domain or leave initialized to 0. */ + if (domain) { + lttng_ctl_copy_lttng_domain(&handle->domain, domain); + } end: return handle; -- 2.34.1