Force usage of assert() condition when NDEBUG is defined
[lttng-tools.git] / src / bin / lttng-sessiond / channel.c
index 46256208d58d11fcd2fc2524be97f2a2cbccded8..e84da039a8e25d1f9a7ef6bfc24d0cdb0d7a0f1d 100644 (file)
@@ -1,19 +1,9 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * 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;
        }
@@ -524,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;
        }
@@ -544,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;
This page took 0.025244 seconds and 4 git commands to generate.