Fix: Delete UST app session on ustctl create error
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 7dbea5c182ca4c6e1a54a89c74a3f0f2c737fe23..5380450f643a31cce3fa3e2eb1bb8ca994fb20ff 100644 (file)
@@ -645,7 +645,7 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
        ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
                        &ua_event->obj);
        if (ret < 0) {
-               if (ret == -EEXIST) {
+               if (ret == -EEXIST || ret == -EPERM) {
                        ret = 0;
                        goto error;
                }
@@ -894,8 +894,9 @@ static struct ust_app_session *create_ust_app_session(
                if (ret < 0) {
                        ERR("Creating session for app pid %d", app->pid);
                        /* This means that the tracer is gone... */
+                       delete_ust_app_session(-1, ua_sess);
                        ua_sess = (void*) -1UL;
-                       goto error;
+                       goto end;
                }
 
                ua_sess->handle = ret;
@@ -909,10 +910,6 @@ static struct ust_app_session *create_ust_app_session(
 
 end:
        return ua_sess;
-
-error:
-       delete_ust_app_session(-1, ua_sess);
-       return NULL;
 }
 
 /*
@@ -1479,7 +1476,7 @@ int ust_app_list_events(struct lttng_event **events)
                        }
                        memcpy(tmp[count].name, uiter.name, LTTNG_UST_SYM_NAME_LEN);
                        tmp[count].loglevel = uiter.loglevel;
-                       tmp[count].type = LTTNG_UST_TRACEPOINT;
+                       tmp[count].type = (enum lttng_event_type) LTTNG_UST_TRACEPOINT;
                        tmp[count].pid = app->pid;
                        tmp[count].enabled = -1;
                        count++;
@@ -2307,7 +2304,7 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock)
        }
 
        ua_sess = create_ust_app_session(usess, app);
-       if (ua_sess == NULL) {
+       if (ua_sess == NULL || ua_sess == (void *) -1UL) {
                goto error;
        }
 
This page took 0.024412 seconds and 4 git commands to generate.