From: Mathieu Desnoyers Date: Wed, 14 Nov 2018 22:49:21 +0000 (-0500) Subject: Fix: create_channel_per_pid: remove channel on error X-Git-Tag: v2.12.0-rc1~761 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=5b951542a175819b62269e6904641f1a26149c96;p=lttng-tools.git Fix: create_channel_per_pid: remove channel on error 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index f97d869e6..2c1b845ad 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -3019,7 +3019,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); @@ -3027,7 +3027,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; } chan_reg_key = ua_chan->key; @@ -3047,9 +3047,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;