+
+ /* Create UST channel */
+ uchan = trace_ust_create_channel(attr, usess->pathname);
+ if (uchan == NULL) {
+ 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);
+
+ /* 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();
+
+ /* Enable channel for global domain */
+ ret = ust_app_create_channel_glb(usess, uchan);
+ break;
+ case LTTNG_DOMAIN_UST_PID:
+ case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
+ case LTTNG_DOMAIN_UST_EXEC_NAME:
+ default:
+ ret = LTTCOMM_NOT_IMPLEMENTED;
+ goto error_free_chan;
+ }
+
+ if (ret < 0 && ret != -EEXIST) {
+ ret = LTTCOMM_UST_CHAN_ENABLE_FAIL;
+ goto error_free_chan;
+ }
+
+ 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);