Fix: Bad error handling when enable channel fails
[lttng-tools.git] / src / bin / lttng-sessiond / channel.c
index 8b9adfba8370894050c5fd214c64c5282682fed8..559c3d154034193381357540e0c0bc7a01f30ce0 100644 (file)
@@ -54,7 +54,8 @@ struct lttng_channel *channel_new_default_attr(int dom)
 
        switch (dom) {
        case LTTNG_DOMAIN_KERNEL:
-               chan->attr.subbuf_size = DEFAULT_KERNEL_CHANNEL_SUBBUF_SIZE;
+               chan->attr.subbuf_size =
+                       default_get_kernel_channel_subbuf_size();
                chan->attr.num_subbuf = DEFAULT_KERNEL_CHANNEL_SUBBUF_NUM;
                chan->attr.output = DEFAULT_KERNEL_CHANNEL_OUTPUT;
                break;
@@ -64,7 +65,7 @@ struct lttng_channel *channel_new_default_attr(int dom)
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
        case LTTNG_DOMAIN_UST_EXEC_NAME:
 #endif
-               chan->attr.subbuf_size = DEFAULT_UST_CHANNEL_SUBBUF_SIZE;
+               chan->attr.subbuf_size = default_get_ust_channel_subbuf_size();
                chan->attr.num_subbuf = DEFAULT_UST_CHANNEL_SUBBUF_NUM;
                chan->attr.output = DEFAULT_UST_CHANNEL_OUTPUT;
                break;
@@ -189,8 +190,16 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain,
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                DBG2("Channel %s being enabled in UST global domain", uchan->name);
-               /* Enable channel for global domain */
-               ret = ust_app_enable_channel_glb(usess, uchan);
+
+               /*
+                * Enable channel for UST global domain on all applications. Ignore
+                * return value here since whatever error we got, it means that the
+                * channel was not created on one or many registered applications and
+                * we can not report this to the user yet. However, at this stage, the
+                * channel was successfully created on the session daemon side so the
+                * enable-channel command is a success.
+                */
+               (void) ust_app_create_channel_glb(usess, uchan);
                break;
 #if 0
        case LTTNG_DOMAIN_UST_PID:
@@ -202,15 +211,6 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain,
                goto error;
        }
 
-       if (ret < 0) {
-               if (ret != -LTTNG_UST_ERR_EXIST) {
-                       ret = LTTNG_ERR_UST_CHAN_ENABLE_FAIL;
-                       goto error;
-               } else {
-                       ret = LTTNG_OK;
-               }
-       }
-
        uchan->enabled = 1;
        DBG2("Channel %s enabled successfully", uchan->name);
 
@@ -239,6 +239,11 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                attr = defattr;
        }
 
+       if (attr->attr.subbuf_size < DEFAULT_UST_CHANNEL_SUBBUF_SIZE) {
+               ret = LTTNG_ERR_INVALID;
+               goto error;
+       }
+
        /*
         * Validate UST buffer size and number of buffers: must both be
         * power of 2 and nonzero. We validate right here for UST,
This page took 0.027863 seconds and 4 git commands to generate.