X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fchannel.c;h=e84da039a8e25d1f9a7ef6bfc24d0cdb0d7a0f1d;hb=a0377dfefe40662ba7d68617bce6ff467114136c;hp=6989fd890f788fe32be95ebdd4a77edbf7e9af1d;hpb=75018ab6aaa9b49e6248b002d9795319a0e5bb9a;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/channel.c b/src/bin/lttng-sessiond/channel.c index 6989fd890..e84da039a 100644 --- a/src/bin/lttng-sessiond/channel.c +++ b/src/bin/lttng-sessiond/channel.c @@ -1,19 +1,9 @@ /* - * Copyright (C) 2011 - David Goulet - * Copyright (C) 2016 - Jérémie Galarneau + * Copyright (C) 2011 David Goulet + * Copyright (C) 2016 Jérémie Galarneau * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -65,7 +55,7 @@ struct lttng_channel *channel_new_default_attr(int dom, switch (dom) { case LTTNG_DOMAIN_KERNEL: - assert(type == LTTNG_BUFFER_GLOBAL); + LTTNG_ASSERT(type == LTTNG_BUFFER_GLOBAL); chan->attr.subbuf_size = default_get_kernel_channel_subbuf_size(); chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM; @@ -156,8 +146,8 @@ int channel_kernel_disable(struct ltt_kernel_session *ksession, int ret; struct ltt_kernel_channel *kchan; - assert(ksession); - assert(channel_name); + LTTNG_ASSERT(ksession); + LTTNG_ASSERT(channel_name); kchan = trace_kernel_get_channel_by_name(channel_name, ksession); if (kchan == NULL) { @@ -188,8 +178,8 @@ int channel_kernel_enable(struct ltt_kernel_session *ksession, { int ret; - assert(ksession); - assert(kchan); + LTTNG_ASSERT(ksession); + LTTNG_ASSERT(kchan); if (kchan->enabled == 0) { ret = kernel_enable_channel(kchan); @@ -239,7 +229,7 @@ int channel_kernel_create(struct ltt_kernel_session *ksession, int ret; struct lttng_channel *defattr = NULL; - assert(ksession); + LTTNG_ASSERT(ksession); /* Creating channel attributes if needed */ if (attr == NULL) { @@ -299,8 +289,8 @@ int channel_ust_enable(struct ltt_ust_session *usess, { int ret = LTTNG_OK; - assert(usess); - assert(uchan); + LTTNG_ASSERT(usess); + LTTNG_ASSERT(uchan); /* If already enabled, everything is OK */ if (uchan->enabled) { @@ -350,7 +340,7 @@ int channel_ust_create(struct ltt_ust_session *usess, enum lttng_domain_type domain = LTTNG_DOMAIN_UST; bool chan_published = false; - assert(usess); + LTTNG_ASSERT(usess); /* Creating channel attributes if needed */ if (attr == NULL) { @@ -407,7 +397,7 @@ int channel_ust_create(struct ltt_ust_session *usess, /* * Invalid subbuffer size if it's lower then the page size. */ - if (attr->attr.subbuf_size < page_size) { + if (attr->attr.subbuf_size < the_page_size) { ret = LTTNG_ERR_INVALID; goto error; } @@ -471,15 +461,6 @@ int channel_ust_create(struct ltt_ust_session *usess, goto error_free_chan; } - if (usess->active) { - /* Enable channel for global domain */ - ret = ust_app_create_channel_glb(usess, uchan); - if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { - ret = LTTNG_ERR_UST_CHAN_FAIL; - goto error_free_chan; - } - } - /* Adding the channel to the channel hash table. */ rcu_read_lock(); if (strncmp(uchan->name, DEFAULT_METADATA_NAME, @@ -533,14 +514,21 @@ int channel_ust_disable(struct ltt_ust_session *usess, { int ret = LTTNG_OK; - assert(usess); - assert(uchan); + LTTNG_ASSERT(usess); + LTTNG_ASSERT(uchan); /* Already disabled */ if (uchan->enabled == 0) { DBG2("Channel UST %s already disabled", uchan->name); goto end; } + + uchan->enabled = 0; + + /* + * If session is inactive we don't notify the tracer right away. We + * wait for the next synchronization. + */ if (!usess->active) { goto end; } @@ -553,8 +541,6 @@ int channel_ust_disable(struct ltt_ust_session *usess, goto error; } - uchan->enabled = 0; - DBG2("Channel %s disabled successfully", uchan->name); return LTTNG_OK;