LTTng sessiond: fix ust app error handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 12 Nov 2011 17:56:50 +0000 (12:56 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 12 Nov 2011 17:56:50 +0000 (12:56 -0500)
Fix incorrect error handling of ust_app_add_channel_all and
ust_app_add_event_all commands. Make ust_app_start_trace take RCU
read-side lock, because this API is exposed outside of ust-app.c.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-sessiond/main.c
lttng-sessiond/ust-app.c

index 5755363c878d6e9c6663763b123c8839a9dc82ac..a40c3693452fd8a464b8121724eed1fe41572658 100644 (file)
@@ -2096,7 +2096,7 @@ static int cmd_enable_channel(struct ltt_session *session,
 
                /* Add channel to all registered applications */
                ret = ust_app_add_channel_all(usess, uchan);
-               if (ret != LTTCOMM_OK) {
+               if (ret != 0) {
                        goto error;
                }
 
index e063fb292ad80511f45331896704bba555898d14..e22a5929ecf77322a68a48a776b5380e999c4eb4 100644 (file)
@@ -808,7 +808,7 @@ int ust_app_add_channel_all(struct ltt_ust_session *usess,
 
                /* Create session on the tracer side and add it to app session HT */
                ua_sess = create_ust_app_session(usess, app);
-               if (ret < 0) {
+               if (ua_sess == NULL) {
                        goto next;
                }
 
@@ -851,7 +851,7 @@ int ust_app_add_event_all(struct ltt_ust_session *usess,
 
                /* Create session on the tracer side and add it to app session HT */
                ua_sess = create_ust_app_session(usess, app);
-               if (ret < 0) {
+               if (ua_sess == NULL) {
                        goto next;
                }
 
@@ -889,15 +889,17 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
 
        DBG("Starting tracing for ust app pid %d", app->key.pid);
 
+       rcu_read_lock();
+
        ua_sess = lookup_session_by_app(usess, app);
        if (ua_sess == NULL) {
                /* Only malloc can failed so something is really wrong */
-               goto error;
+               goto error_rcu_unlock;
        }
 
        ret = create_ust_app_metadata(ua_sess, usess->pathname, app);
        if (ret < 0) {
-               goto error;
+               goto error_rcu_unlock;
        }
 
        /* For each channel */
@@ -912,7 +914,7 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
                        ustream = zmalloc(sizeof(*ustream));
                        if (ustream == NULL) {
                                PERROR("zmalloc ust stream");
-                               continue;
+                               goto error_rcu_unlock;
                        }
 
                        ret = ustctl_create_stream(app->key.sock, ua_chan->obj,
@@ -943,22 +945,24 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
        /* Setup UST consumer socket and send fds to it */
        ret = ust_consumer_send_session(usess->consumer_fd, ua_sess);
        if (ret < 0) {
-               goto error;
+               goto error_rcu_unlock;
        }
 
        /* This start the UST tracing */
        ret = ustctl_start_session(app->key.sock, ua_sess->handle);
        if (ret < 0) {
                ERR("Error starting tracing for app pid: %d", app->key.pid);
-               goto error;
+               goto error_rcu_unlock;
        }
+       rcu_read_unlock();
 
        /* Quiescent wait after starting trace */
        ustctl_wait_quiescent(app->key.sock);
 
        return 0;
 
-error:
+error_rcu_unlock:
+       rcu_read_unlock();
        return -1;
 }
 
This page took 0.030597 seconds and 4 git commands to generate.