Fix disable/enable channel when app registers
[lttng-tools.git] / lttng-sessiond / main.c
index 7e4000a0fd1183365a9ccc7746e47297f0cb9d66..7d898a94e19938ebbe697ef686d3b3bef95d9091 100644 (file)
@@ -2191,6 +2191,12 @@ static int cmd_disable_channel(struct ltt_session *session,
                        goto error;
                }
 
+               /* Already disabled */
+               if (!uchan->enabled) {
+                       DBG2("UST channel %s already disabled", channel_name);
+                       break;
+               }
+
                ret = ust_app_disable_channel_glb(usess, uchan);
                if (ret < 0) {
                        ret = LTTCOMM_UST_DISABLE_FAIL;
@@ -2299,28 +2305,32 @@ static int cmd_enable_channel(struct ltt_session *session,
                                goto error;
                        }
 
-                       rcu_read_lock();
-                       hashtable_add_unique(usess->domain_global.channels, &uchan->node);
-                       rcu_read_unlock();
-                       DBG2("UST channel %s added to global domain HT", attr->name);
-
                        /* Add channel to all registered applications */
                        ret = ust_app_create_channel_glb(usess, uchan);
                        if (ret != 0) {
                                ret = LTTCOMM_UST_CHAN_FAIL;
                                goto error;
                        }
+
+                       rcu_read_lock();
+                       hashtable_add_unique(usess->domain_global.channels, &uchan->node);
+                       rcu_read_unlock();
+
+                       DBG2("UST channel %s added to global domain HT", attr->name);
                } else {
                        /* If already enabled, everything is OK */
                        if (uchan->enabled) {
-                               ret = LTTCOMM_OK;
-                               goto error;
+                               break;
                        }
 
                        ret = ust_app_enable_channel_glb(usess, uchan);
                        if (ret < 0) {
-                               ret = LTTCOMM_UST_ENABLE_FAIL;
-                               goto error;
+                               if (ret != -EEXIST) {
+                                       ret = LTTCOMM_UST_CHAN_ENABLE_FAIL;
+                                       goto error;
+                               } else {
+                                       ret = LTTCOMM_OK;
+                               }
                        }
                }
 
This page took 0.024512 seconds and 4 git commands to generate.