Fix multiple error handling for UST tracing
[lttng-tools.git] / lttng-sessiond / channel.c
index 5a22d2937f22a9d95de60f6a7126ff28671402b7..0e8b1672086b7031b950ba92b4e32fd7ea28e39e 100644 (file)
 #include <unistd.h>
 
 #include <lttng/lttng.h>
+#include <lttng-ht.h>
 #include <lttng-sessiond-comm.h>
 #include <lttngerr.h>
 
 #include "channel.h"
-#include "hashtable.h"
 #include "kernel.h"
 #include "ust-ctl.h"
 #include "utils.h"
@@ -216,7 +216,6 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                struct lttng_channel *attr)
 {
        int ret = LTTCOMM_OK;
-       struct cds_lfht *chan_ht;
        struct ltt_ust_channel *uchan = NULL;
        struct lttng_channel *defattr = NULL;
 
@@ -236,11 +235,11 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                ret = LTTCOMM_FATAL;
                goto error;
        }
+       uchan->enabled = 1;
 
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                DBG2("Channel %s being created in UST global domain", uchan->name);
-               chan_ht = usess->domain_global.channels;
 
                /* Enable channel for global domain */
                ret = ust_app_create_channel_glb(usess, uchan);
@@ -258,14 +257,21 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                goto error_free_chan;
        }
 
-       uchan->enabled = 1;
-       hashtable_add_unique(chan_ht, &uchan->node);
+       /* Adding the channel to the channel hash table. */
+       rcu_read_lock();
+       lttng_ht_add_unique_str(usess->domain_global.channels, &uchan->node);
+       rcu_read_unlock();
+
        DBG2("Channel %s created successfully", uchan->name);
 
        free(defattr);
        return LTTCOMM_OK;
 
 error_free_chan:
+       /*
+        * No need to remove the channel from the hash table because at this point
+        * it was not added hence the direct call and no call_rcu().
+        */
        trace_ust_destroy_channel(uchan);
 error:
        free(defattr);
@@ -279,7 +285,6 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
                struct ltt_ust_channel *uchan)
 {
        int ret = LTTCOMM_OK;
-       struct cds_lfht *chan_ht;
 
        /* Already disabled */
        if (uchan->enabled == 0) {
@@ -291,8 +296,6 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                DBG2("Channel %s being disabled in UST global domain", uchan->name);
-               chan_ht = usess->domain_global.channels;
-
                /* Disable channel for global domain */
                ret = ust_app_disable_channel_glb(usess, uchan);
                break;
This page took 0.024438 seconds and 4 git commands to generate.