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>
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);
if (ret != -ENOTCONN) {
ERR("Error sending channel to application");
}
- goto error;
+ goto error_remove_from_registry;
}
chan_reg_key = ua_chan->key;
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;