Fix: create_channel_per_pid: remove channel on error
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 14 Nov 2018 22:49:21 +0000 (17:49 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 16 Nov 2018 22:45:05 +0000 (17:45 -0500)
The notification system of the session daemon tracks the lifetime
of per-pid buffers (in effect, channel keys) using two hooks:
  - the successful completion of create_channel_per_pid()
  - the deletion of the channel from an application's registry

Multiple error paths in create_channel_per_pid() can leave a channel
in an app's registry without notifying the notification system of its
existence.

When the channel is finally cleaned-up, the channel deletion hook will
inform the notification system that the channel should be deleted,
resulting in an error as that channel was previously unknown.

This fix ensures we remove the application's channel from its registry
on error (with the notify parameter set to 'false'), thus ensuring
that the notification system never tracks the incomplete channel.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-app.c

index 48da16b1072a6264949a889c8298958e2c33d4d3..62a6e9c0916467772ecb96511e1f712cd26edcc9 100644 (file)
@@ -3012,7 +3012,7 @@ static int create_channel_per_pid(struct ust_app *app,
        if (ret < 0) {
                ERR("Error creating UST channel \"%s\" on the consumer daemon",
                        ua_chan->name);
-               goto error;
+               goto error_remove_from_registry;
        }
 
        ret = send_channel_pid_to_ust(app, ua_sess, ua_chan);
@@ -3020,7 +3020,7 @@ static int create_channel_per_pid(struct ust_app *app,
                if (ret != -ENOTCONN) {
                        ERR("Error sending channel to application");
                }
-               goto error;
+               goto error_remove_from_registry;
        }
 
        session = session_find_by_id(ua_sess->tracing_id);
@@ -3043,9 +3043,13 @@ static int create_channel_per_pid(struct ust_app *app,
        if (cmd_ret != LTTNG_OK) {
                ret = - (int) cmd_ret;
                ERR("Failed to add channel to notification thread");
-               goto error;
+               goto error_remove_from_registry;
        }
 
+error_remove_from_registry:
+       if (ret) {
+               ust_registry_channel_del_free(registry, ua_chan->key, false);
+       }
 error:
        rcu_read_unlock();
        return ret;
This page took 0.029276 seconds and 5 git commands to generate.