Fix: liblttng-ctl comm: lttng_channel is not packed
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 83ad957fcdb08912e3dd045940609d01c5e4efda..add0a78a82f781587588f59613b413b7be47c70d 100644 (file)
@@ -6,66 +6,69 @@
  *
  */
 
+
 #define _LGPL_SOURCE
 #include <assert.h>
 #include <inttypes.h>
+#include <stdio.h>
+#include <sys/stat.h>
 #include <urcu/list.h>
 #include <urcu/uatomic.h>
-#include <sys/stat.h>
-#include <stdio.h>
 
-#include <common/defaults.h>
+#include <common/buffer-view.h>
 #include <common/common.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/relayd/relayd.h>
-#include <common/utils.h>
 #include <common/compat/string.h>
-#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/defaults.h>
 #include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
-#include <common/payload.h>
+#include <common/kernel-ctl/kernel-ctl.h>
 #include <common/payload-view.h>
+#include <common/payload.h>
+#include <common/relayd/relayd.h>
+#include <common/sessiond-comm/sessiond-comm.h>
+#include <common/string-utils/string-utils.h>
 #include <common/trace-chunk.h>
-#include <lttng/location-internal.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <lttng/condition/condition.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/event-rule.h>
-#include <lttng/condition/event-rule-internal.h>
-#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <common/utils.h>
+#include <lttng/action/action-internal.h>
 #include <lttng/action/action.h>
-#include <lttng/channel.h>
 #include <lttng/channel-internal.h>
-#include <lttng/rotate-internal.h>
+#include <lttng/channel.h>
+#include <lttng/condition/condition-internal.h>
+#include <lttng/condition/condition.h>
+#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches.h>
+#include <lttng/error-query-internal.h>
+#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule.h>
 #include <lttng/location-internal.h>
-#include <lttng/session-internal.h>
-#include <lttng/userspace-probe-internal.h>
-#include <lttng/session-descriptor-internal.h>
 #include <lttng/lttng-error.h>
+#include <lttng/rotate-internal.h>
+#include <lttng/session-descriptor-internal.h>
+#include <lttng/session-internal.h>
 #include <lttng/tracker.h>
-#include <common/string-utils/string-utils.h>
+#include <lttng/trigger/trigger-internal.h>
+#include <lttng/userspace-probe-internal.h>
 
+#include "agent-thread.h"
+#include "agent.h"
+#include "buffer-registry.h"
 #include "channel.h"
+#include "cmd.h"
 #include "consumer.h"
+#include "event-notifier-error-accounting.h"
 #include "event.h"
 #include "health-sessiond.h"
-#include "kernel.h"
 #include "kernel-consumer.h"
+#include "kernel.h"
 #include "lttng-sessiond.h"
-#include "utils.h"
 #include "lttng-syscall.h"
-#include "agent.h"
-#include "buffer-registry.h"
-#include "notification-thread.h"
 #include "notification-thread-commands.h"
+#include "notification-thread.h"
 #include "rotate.h"
 #include "rotation-thread.h"
+#include "session.h"
 #include "timer.h"
-#include "agent-thread.h"
 #include "tracker.h"
-
-#include "cmd.h"
+#include "utils.h"
 
 /* Sleep for 100ms between each check for the shm path's deletion. */
 #define SESSION_DESTROY_SHM_PATH_CHECK_DELAY_US 100000
@@ -118,6 +121,10 @@ static int cmd_enable_event_internal(struct ltt_session *session,
                struct lttng_bytecode *filter,
                struct lttng_event_exclusion *exclusion,
                int wpipe);
+static int cmd_enable_channel_internal(struct ltt_session *session,
+               const struct lttng_domain *domain,
+               const struct lttng_channel *_attr,
+               int wpipe);
 
 /*
  * Create a session path used by list_lttng_sessions for the case that the
@@ -288,118 +295,6 @@ end:
        return ret;
 }
 
-/*
- * Fill lttng_channel array of all channels.
- */
-static ssize_t list_lttng_channels(enum lttng_domain_type domain,
-               struct ltt_session *session, struct lttng_channel *channels,
-               struct lttng_channel_extended *chan_exts)
-{
-       int i = 0, ret = 0;
-       struct ltt_kernel_channel *kchan;
-
-       DBG("Listing channels for session %s", session->name);
-
-       switch (domain) {
-       case LTTNG_DOMAIN_KERNEL:
-               /* Kernel channels */
-               if (session->kernel_session != NULL) {
-                       cds_list_for_each_entry(kchan,
-                                       &session->kernel_session->channel_list.head, list) {
-                               uint64_t discarded_events, lost_packets;
-                               struct lttng_channel_extended *extended;
-
-                               extended = (struct lttng_channel_extended *)
-                                               kchan->channel->attr.extended.ptr;
-
-                               ret = get_kernel_runtime_stats(session, kchan,
-                                               &discarded_events, &lost_packets);
-                               if (ret < 0) {
-                                       goto end;
-                               }
-                               /* Copy lttng_channel struct to array */
-                               memcpy(&channels[i], kchan->channel, sizeof(struct lttng_channel));
-                               channels[i].enabled = kchan->enabled;
-                               chan_exts[i].discarded_events =
-                                               discarded_events;
-                               chan_exts[i].lost_packets = lost_packets;
-                               chan_exts[i].monitor_timer_interval =
-                                               extended->monitor_timer_interval;
-                               chan_exts[i].blocking_timeout = 0;
-                               i++;
-                       }
-               }
-               break;
-       case LTTNG_DOMAIN_UST:
-       {
-               struct lttng_ht_iter iter;
-               struct ltt_ust_channel *uchan;
-
-               rcu_read_lock();
-               cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
-                               &iter.iter, uchan, node.node) {
-                       uint64_t discarded_events = 0, lost_packets = 0;
-
-                       if (lttng_strncpy(channels[i].name, uchan->name,
-                                       LTTNG_SYMBOL_NAME_LEN)) {
-                               break;
-                       }
-                       channels[i].attr.overwrite = uchan->attr.overwrite;
-                       channels[i].attr.subbuf_size = uchan->attr.subbuf_size;
-                       channels[i].attr.num_subbuf = uchan->attr.num_subbuf;
-                       channels[i].attr.switch_timer_interval =
-                               uchan->attr.switch_timer_interval;
-                       channels[i].attr.read_timer_interval =
-                               uchan->attr.read_timer_interval;
-                       channels[i].enabled = uchan->enabled;
-                       channels[i].attr.tracefile_size = uchan->tracefile_size;
-                       channels[i].attr.tracefile_count = uchan->tracefile_count;
-
-                       /*
-                        * Map enum lttng_ust_output to enum lttng_event_output.
-                        */
-                       switch (uchan->attr.output) {
-                       case LTTNG_UST_ABI_MMAP:
-                               channels[i].attr.output = LTTNG_EVENT_MMAP;
-                               break;
-                       default:
-                               /*
-                                * LTTNG_UST_MMAP is the only supported UST
-                                * output mode.
-                                */
-                               assert(0);
-                               break;
-                       }
-
-                       chan_exts[i].monitor_timer_interval =
-                                       uchan->monitor_timer_interval;
-                       chan_exts[i].blocking_timeout =
-                               uchan->attr.u.s.blocking_timeout;
-
-                       ret = get_ust_runtime_stats(session, uchan,
-                                       &discarded_events, &lost_packets);
-                       if (ret < 0) {
-                               break;
-                       }
-                       chan_exts[i].discarded_events = discarded_events;
-                       chan_exts[i].lost_packets = lost_packets;
-                       i++;
-               }
-               rcu_read_unlock();
-               break;
-       }
-       default:
-               break;
-       }
-
-end:
-       if (ret < 0) {
-               return -LTTNG_ERR_FATAL;
-       } else {
-               return LTTNG_OK;
-       }
-}
-
 static int append_extended_info(const char *filter_expression,
                struct lttng_event_exclusion *exclusion,
                struct lttng_userspace_probe_location *probe_location,
@@ -678,34 +573,34 @@ static int list_lttng_kernel_events(char *channel_name,
                event.filter = (unsigned char) !!kevent->filter_expression;
 
                switch (kevent->event->instrumentation) {
-               case LTTNG_KERNEL_TRACEPOINT:
+               case LTTNG_KERNEL_ABI_TRACEPOINT:
                        event.type = LTTNG_EVENT_TRACEPOINT;
                        break;
-               case LTTNG_KERNEL_KRETPROBE:
+               case LTTNG_KERNEL_ABI_KRETPROBE:
                        event.type = LTTNG_EVENT_FUNCTION;
                        memcpy(&event.attr.probe, &kevent->event->u.kprobe,
-                                       sizeof(struct lttng_kernel_kprobe));
+                                       sizeof(struct lttng_kernel_abi_kprobe));
                        break;
-               case LTTNG_KERNEL_KPROBE:
+               case LTTNG_KERNEL_ABI_KPROBE:
                        event.type = LTTNG_EVENT_PROBE;
                        memcpy(&event.attr.probe, &kevent->event->u.kprobe,
-                                       sizeof(struct lttng_kernel_kprobe));
+                                       sizeof(struct lttng_kernel_abi_kprobe));
                        break;
-               case LTTNG_KERNEL_UPROBE:
+               case LTTNG_KERNEL_ABI_UPROBE:
                        event.type = LTTNG_EVENT_USERSPACE_PROBE;
                        break;
-               case LTTNG_KERNEL_FUNCTION:
+               case LTTNG_KERNEL_ABI_FUNCTION:
                        event.type = LTTNG_EVENT_FUNCTION;
                        memcpy(&event.attr.ftrace, &kevent->event->u.ftrace,
-                                       sizeof(struct lttng_kernel_function));
+                                       sizeof(struct lttng_kernel_abi_function));
                        break;
-               case LTTNG_KERNEL_NOOP:
+               case LTTNG_KERNEL_ABI_NOOP:
                        event.type = LTTNG_EVENT_NOOP;
                        break;
-               case LTTNG_KERNEL_SYSCALL:
+               case LTTNG_KERNEL_ABI_SYSCALL:
                        event.type = LTTNG_EVENT_SYSCALL;
                        break;
-               case LTTNG_KERNEL_ALL:
+               case LTTNG_KERNEL_ABI_ALL:
                        /* fall-through. */
                default:
                        assert(0);
@@ -1357,50 +1252,95 @@ error:
  *
  * The wpipe arguments is used as a notifier for the kernel thread.
  */
-int cmd_enable_channel(struct ltt_session *session,
-               const struct lttng_domain *domain, const struct lttng_channel *_attr, int wpipe)
+int cmd_enable_channel(struct command_ctx *cmd_ctx, int sock, int wpipe)
+{
+       int ret;
+       size_t channel_len;
+       ssize_t sock_recv_len;
+       struct lttng_channel *channel = NULL;
+       struct lttng_buffer_view view;
+       struct lttng_dynamic_buffer channel_buffer;
+       const struct lttng_domain command_domain = cmd_ctx->lsm.domain;
+
+       lttng_dynamic_buffer_init(&channel_buffer);
+       channel_len = (size_t) cmd_ctx->lsm.u.channel.length;
+       ret = lttng_dynamic_buffer_set_size(&channel_buffer, channel_len);
+       if (ret) {
+               ret = LTTNG_ERR_NOMEM;
+               goto end;
+       }
+
+       sock_recv_len = lttcomm_recv_unix_sock(sock, channel_buffer.data,
+                       channel_len);
+       if (sock_recv_len < 0 || sock_recv_len != channel_len) {
+               ERR("Failed to receive \"enable channel\" command payload");
+               ret = LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       view = lttng_buffer_view_from_dynamic_buffer(&channel_buffer, 0, channel_len);
+       if (!lttng_buffer_view_is_valid(&view)) {
+               ret = LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       if (lttng_channel_create_from_buffer(&view, &channel) != channel_len) {
+               ERR("Invalid channel payload received in \"enable channel\" command");
+               ret = LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       ret = cmd_enable_channel_internal(
+                       cmd_ctx->session, &command_domain, channel, wpipe);
+
+end:
+       lttng_dynamic_buffer_reset(&channel_buffer);
+       lttng_channel_destroy(channel);
+       return ret;
+}
+
+static int cmd_enable_channel_internal(struct ltt_session *session,
+               const struct lttng_domain *domain,
+               const struct lttng_channel *_attr,
+               int wpipe)
 {
        int ret;
        struct ltt_ust_session *usess = session->ust_session;
        struct lttng_ht *chan_ht;
        size_t len;
-       struct lttng_channel attr;
+       struct lttng_channel *attr = NULL;
 
        assert(session);
        assert(_attr);
        assert(domain);
 
-       attr = *_attr;
-       len = lttng_strnlen(attr.name, sizeof(attr.name));
+       attr = lttng_channel_copy(_attr);
+       if (!attr) {
+               ret = -LTTNG_ERR_NOMEM;
+               goto end;
+       }
+
+       len = lttng_strnlen(attr->name, sizeof(attr->name));
 
        /* Validate channel name */
-       if (attr.name[0] == '.' ||
-               memchr(attr.name, '/', len) != NULL) {
+       if (attr->name[0] == '.' ||
+               memchr(attr->name, '/', len) != NULL) {
                ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
                goto end;
        }
 
-       DBG("Enabling channel %s for session %s", attr.name, session->name);
+       DBG("Enabling channel %s for session %s", attr->name, session->name);
 
        rcu_read_lock();
 
-       /*
-        * Don't try to enable a channel if the session has been started at
-        * some point in time before. The tracer does not allow it.
-        */
-       if (session->has_been_started) {
-               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
-               goto error;
-       }
-
        /*
         * If the session is a live session, remove the switch timer, the
         * live timer does the same thing but sends also synchronisation
         * beacons for inactive streams.
         */
        if (session->live_timer > 0) {
-               attr.attr.live_timer_interval = session->live_timer;
-               attr.attr.switch_timer_interval = 0;
+               attr->attr.live_timer_interval = session->live_timer;
+               attr->attr.switch_timer_interval = 0;
        }
 
        /* Check for feature support */
@@ -1412,8 +1352,8 @@ int cmd_enable_channel(struct ltt_session *session,
                        WARN("Kernel tracer does not support buffer monitoring. "
                                        "Setting the monitor interval timer to 0 "
                                        "(disabled) for channel '%s' of session '%s'",
-                                       attr.name, session->name);
-                       lttng_channel_set_monitor_timer_interval(&attr, 0);
+                                       attr->name, session->name);
+                       lttng_channel_set_monitor_timer_interval(attr, 0);
                }
                break;
        }
@@ -1438,16 +1378,26 @@ int cmd_enable_channel(struct ltt_session *session,
        {
                struct ltt_kernel_channel *kchan;
 
-               kchan = trace_kernel_get_channel_by_name(attr.name,
-                               session->kernel_session);
+               kchan = trace_kernel_get_channel_by_name(
+                               attr->name, session->kernel_session);
                if (kchan == NULL) {
+                       /*
+                        * Don't try to create a channel if the session has been started at
+                        * some point in time before. The tracer does not allow it.
+                        */
+                       if (session->has_been_started) {
+                               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+                               goto error;
+                       }
+
                        if (session->snapshot.nb_output > 0 ||
                                        session->snapshot_mode) {
                                /* Enforce mmap output for snapshot sessions. */
-                               attr.attr.output = LTTNG_EVENT_MMAP;
+                               attr->attr.output = LTTNG_EVENT_MMAP;
                        }
-                       ret = channel_kernel_create(session->kernel_session, &attr, wpipe);
-                       if (attr.name[0] != '\0') {
+                       ret = channel_kernel_create(
+                                       session->kernel_session, attr, wpipe);
+                       if (attr->name[0] != '\0') {
                                session->kernel_session->has_non_default_channel = 1;
                        }
                } else {
@@ -1477,19 +1427,19 @@ int cmd_enable_channel(struct ltt_session *session,
                 * adhered to.
                 */
                if (domain->type == LTTNG_DOMAIN_JUL) {
-                       if (strncmp(attr.name, DEFAULT_JUL_CHANNEL_NAME,
+                       if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
                                ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
                        }
                } else if (domain->type == LTTNG_DOMAIN_LOG4J) {
-                       if (strncmp(attr.name, DEFAULT_LOG4J_CHANNEL_NAME,
+                       if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
                                ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
                        }
                } else if (domain->type == LTTNG_DOMAIN_PYTHON) {
-                       if (strncmp(attr.name, DEFAULT_PYTHON_CHANNEL_NAME,
+                       if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
                                ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
@@ -1498,10 +1448,19 @@ int cmd_enable_channel(struct ltt_session *session,
 
                chan_ht = usess->domain_global.channels;
 
-               uchan = trace_ust_find_channel_by_name(chan_ht, attr.name);
+               uchan = trace_ust_find_channel_by_name(chan_ht, attr->name);
                if (uchan == NULL) {
-                       ret = channel_ust_create(usess, &attr, domain->buf_type);
-                       if (attr.name[0] != '\0') {
+                       /*
+                        * Don't try to create a channel if the session has been started at
+                        * some point in time before. The tracer does not allow it.
+                        */
+                       if (session->has_been_started) {
+                               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+                               goto error;
+                       }
+
+                       ret = channel_ust_create(usess, attr, domain->buf_type);
+                       if (attr->name[0] != '\0') {
                                usess->has_non_default_channel = 1;
                        }
                } else {
@@ -1514,12 +1473,13 @@ int cmd_enable_channel(struct ltt_session *session,
                goto error;
        }
 
-       if (ret == LTTNG_OK && attr.attr.output != LTTNG_EVENT_MMAP) {
+       if (ret == LTTNG_OK && attr->attr.output != LTTNG_EVENT_MMAP) {
                session->has_non_mmap_channel = true;
        }
 error:
        rcu_read_unlock();
 end:
+       lttng_channel_destroy(attr);
        return ret;
 }
 
@@ -2146,7 +2106,8 @@ static int _cmd_enable_event(struct ltt_session *session,
                                goto error;
                        }
 
-                       ret = cmd_enable_channel(session, domain, attr, wpipe);
+                       ret = cmd_enable_channel_internal(
+                                       session, domain, attr, wpipe);
                        if (ret != LTTNG_OK) {
                                goto error;
                        }
@@ -2285,7 +2246,8 @@ static int _cmd_enable_event(struct ltt_session *session,
                                goto error;
                        }
 
-                       ret = cmd_enable_channel(session, domain, attr, wpipe);
+                       ret = cmd_enable_channel_internal(
+                                       session, domain, attr, wpipe);
                        if (ret != LTTNG_OK) {
                                goto error;
                        }
@@ -3238,6 +3200,7 @@ void cmd_destroy_session_reply(const struct ltt_session *session,
        payload_size_before_location = payload.size;
        comm_ret = lttng_trace_archive_location_serialize(location,
                        &payload);
+       lttng_trace_archive_location_put(location);
        if (comm_ret < 0) {
                ERR("Failed to serialize the location of the trace archive produced during the destruction of session \"%s\"",
                                session->name);
@@ -3590,74 +3553,145 @@ error:
 /*
  * Command LTTNG_LIST_CHANNELS processed by the client thread.
  */
-ssize_t cmd_list_channels(enum lttng_domain_type domain,
-               struct ltt_session *session, struct lttng_channel **channels)
+enum lttng_error_code cmd_list_channels(enum lttng_domain_type domain,
+               struct ltt_session *session,
+               struct lttng_payload *payload)
 {
-       ssize_t nb_chan = 0, payload_size = 0, ret;
+       int ret = 0;
+       unsigned int i = 0;
+       struct lttcomm_list_command_header cmd_header = {};
+       size_t cmd_header_offset;
+       enum lttng_error_code ret_code;
+
+       assert(session);
+       assert(payload);
+
+       DBG("Listing channels for session %s", session->name);
+
+       cmd_header_offset = payload->buffer.size;
+
+       /* Reserve space for command reply header. */
+       ret = lttng_dynamic_buffer_set_size(&payload->buffer,
+                       cmd_header_offset + sizeof(cmd_header));
+       if (ret) {
+               ret_code = LTTNG_ERR_NOMEM;
+               goto end;
+       }
 
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
+       {
+               /* Kernel channels */
+               struct ltt_kernel_channel *kchan;
                if (session->kernel_session != NULL) {
-                       nb_chan = session->kernel_session->channel_count;
-               }
-               DBG3("Number of kernel channels %zd", nb_chan);
-               if (nb_chan <= 0) {
-                       ret = -LTTNG_ERR_KERN_CHAN_NOT_FOUND;
-                       goto end;
-               }
-               break;
-       case LTTNG_DOMAIN_UST:
-               if (session->ust_session != NULL) {
-                       rcu_read_lock();
-                       nb_chan = lttng_ht_get_count(
-                               session->ust_session->domain_global.channels);
-                       rcu_read_unlock();
-               }
-               DBG3("Number of UST global channels %zd", nb_chan);
-               if (nb_chan < 0) {
-                       ret = -LTTNG_ERR_UST_CHAN_NOT_FOUND;
-                       goto end;
-               }
-               break;
-       default:
-               ret = -LTTNG_ERR_UND;
-               goto end;
-       }
+                       cds_list_for_each_entry(kchan,
+                                       &session->kernel_session->channel_list.head, list) {
+                               uint64_t discarded_events, lost_packets;
+                               struct lttng_channel_extended *extended;
 
-       if (nb_chan > 0) {
-               const size_t channel_size = sizeof(struct lttng_channel) +
-                       sizeof(struct lttng_channel_extended);
-               struct lttng_channel_extended *channel_exts;
+                               extended = (struct lttng_channel_extended *)
+                                               kchan->channel->attr.extended.ptr;
 
-               payload_size = nb_chan * channel_size;
-               *channels = zmalloc(payload_size);
-               if (*channels == NULL) {
-                       ret = -LTTNG_ERR_FATAL;
-                       goto end;
-               }
+                               ret = get_kernel_runtime_stats(session, kchan,
+                                               &discarded_events, &lost_packets);
+                               if (ret < 0) {
+                                       ret_code = LTTNG_ERR_UNK;
+                                       goto end;
+                               }
 
-               channel_exts = ((void *) *channels) +
-                               (nb_chan * sizeof(struct lttng_channel));
-               ret = list_lttng_channels(domain, session, *channels, channel_exts);
-               if (ret != LTTNG_OK) {
-                       free(*channels);
-                       *channels = NULL;
-                       goto end;
+                               /*
+                                * Update the discarded_events and lost_packets
+                                * count for the channel
+                                */
+                               extended->discarded_events = discarded_events;
+                               extended->lost_packets = lost_packets;
+
+                               ret = lttng_channel_serialize(
+                                               kchan->channel, &payload->buffer);
+                               if (ret) {
+                                       ERR("Failed to serialize lttng_channel: channel name = '%s'",
+                                                       kchan->channel->name);
+                                       ret_code = LTTNG_ERR_UNK;
+                                       goto end;
+                               }
+
+                               i++;
+                       }
                }
-       } else {
-               *channels = NULL;
+               break;
        }
+       case LTTNG_DOMAIN_UST:
+       {
+               struct lttng_ht_iter iter;
+               struct ltt_ust_channel *uchan;
 
-       ret = payload_size;
-end:
-       return ret;
-}
+               rcu_read_lock();
+               cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
+                               &iter.iter, uchan, node.node) {
+                       uint64_t discarded_events = 0, lost_packets = 0;
+                       struct lttng_channel *channel = NULL;
+                       struct lttng_channel_extended *extended;
 
-/*
- * Command LTTNG_LIST_EVENTS processed by the client thread.
- */
-ssize_t cmd_list_events(enum lttng_domain_type domain,
-               struct ltt_session *session, char *channel_name,
+                       channel = trace_ust_channel_to_lttng_channel(uchan);
+                       if (!channel) {
+                               ret = LTTNG_ERR_NOMEM;
+                               break;
+                       }
+
+                       extended = (struct lttng_channel_extended *)
+                                                  channel->attr.extended.ptr;
+
+                       ret = get_ust_runtime_stats(session, uchan,
+                                       &discarded_events, &lost_packets);
+                       if (ret < 0) {
+                               lttng_channel_destroy(channel);
+                               ret_code = LTTNG_ERR_UNK;
+                               break;
+                       }
+
+                       extended->discarded_events = discarded_events;
+                       extended->lost_packets = lost_packets;
+
+                       ret = lttng_channel_serialize(
+                                       channel, &payload->buffer);
+                       if (ret) {
+                               ERR("Failed to serialize lttng_channel: channel name = '%s'",
+                                               channel->name);
+                               ret_code = LTTNG_ERR_UNK;
+                               ret = -1;
+                               break;
+                       }
+
+                       i++;
+               }
+               rcu_read_unlock();
+               break;
+       }
+       default:
+               break;
+       }
+
+       if (i > UINT32_MAX) {
+               ERR("Channel count would overflow the channel listing command's reply");
+               ret_code = LTTNG_ERR_OVERFLOW;
+               goto end;
+       }
+
+       /* Update command reply header. */
+       cmd_header.count = (uint32_t) i;
+       memcpy(payload->buffer.data + cmd_header_offset, &cmd_header,
+                       sizeof(cmd_header));
+       ret_code = LTTNG_OK;
+
+end:
+       return ret_code;
+}
+
+/*
+ * Command LTTNG_LIST_EVENTS processed by the client thread.
+ */
+ssize_t cmd_list_events(enum lttng_domain_type domain,
+               struct ltt_session *session, char *channel_name,
                struct lttng_payload *payload)
 {
        int ret = 0;
@@ -4293,38 +4327,107 @@ end:
        return ret;
 }
 
-static enum lttng_error_code trigger_modifies_event_notifier(
-               const struct lttng_trigger *trigger, bool *adds_event_notifier)
+static
+enum lttng_error_code synchronize_tracer_notifier_register(
+               struct notification_thread_handle *notification_thread,
+               struct lttng_trigger *trigger, const struct lttng_credentials *cmd_creds)
 {
-       enum lttng_error_code ret_code = LTTNG_OK;
-       const struct lttng_condition *condition = NULL;
+       enum lttng_error_code ret_code;
+       const struct lttng_condition *condition =
+                       lttng_trigger_get_const_condition(trigger);
+       const char *trigger_name;
+       uid_t trigger_owner;
+       enum lttng_trigger_status trigger_status;
+       const enum lttng_domain_type trigger_domain =
+                       lttng_trigger_get_underlying_domain_type_restriction(
+                                       trigger);
 
-       condition = lttng_trigger_get_const_condition(trigger);
-       if (!condition) {
-               ret_code = LTTNG_ERR_INVALID_TRIGGER;
-               goto end;
+       trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
+       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+       assert(condition);
+       assert(lttng_condition_get_type(condition) ==
+                       LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+
+       trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+       trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
+                       trigger_name : "(anonymous)";
+
+       session_lock_list();
+       switch (trigger_domain) {
+       case LTTNG_DOMAIN_KERNEL:
+       {
+               ret_code = kernel_register_event_notifier(trigger, cmd_creds);
+               if (ret_code != LTTNG_OK) {
+                       enum lttng_error_code notif_thread_unregister_ret;
+
+                       notif_thread_unregister_ret =
+                                       notification_thread_command_unregister_trigger(
+                                               notification_thread, trigger);
+
+                       if (notif_thread_unregister_ret != LTTNG_OK) {
+                               /* Return the original error code. */
+                               ERR("Failed to unregister trigger from notification thread during error recovery: trigger name = '%s', trigger owner uid = %d, error code = %d",
+                                               trigger_name,
+                                               (int) trigger_owner,
+                                               ret_code);
+                       }
+               }
+               break;
        }
+       case LTTNG_DOMAIN_UST:
+               ust_app_global_update_all_event_notifier_rules();
+               break;
+       case LTTNG_DOMAIN_JUL:
+       case LTTNG_DOMAIN_LOG4J:
+       case LTTNG_DOMAIN_PYTHON:
+       {
+               /* Agent domains. */
+               struct agent *agt = agent_find_by_event_notifier_domain(
+                               trigger_domain);
 
-       *adds_event_notifier = lttng_condition_get_type(condition) ==
-                       LTTNG_CONDITION_TYPE_EVENT_RULE_HIT;
-end:
+               if (!agt) {
+                       agt = agent_create(trigger_domain);
+                       if (!agt) {
+                               ret_code = LTTNG_ERR_NOMEM;
+                               goto end_unlock_session_list;
+                       }
+
+                       agent_add(agt, the_trigger_agents_ht_by_domain);
+               }
+
+               ret_code = trigger_agent_enable(trigger, agt);
+               if (ret_code != LTTNG_OK) {
+                       goto end_unlock_session_list;
+               }
+
+               break;
+       }
+       case LTTNG_DOMAIN_NONE:
+       default:
+               abort();
+       }
+
+       ret_code = LTTNG_OK;
+end_unlock_session_list:
+       session_unlock_list();
        return ret_code;
 }
 
 enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_creds,
                struct lttng_trigger *trigger,
+               bool is_trigger_anonymous,
                struct notification_thread_handle *notification_thread,
                struct lttng_trigger **return_trigger)
 {
        enum lttng_error_code ret_code;
-       bool must_update_event_notifiers;
        const char *trigger_name;
        uid_t trigger_owner;
        enum lttng_trigger_status trigger_status;
 
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
        trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
-                       trigger_name : "(unnamed)";
+                       trigger_name : "(anonymous)";
 
        trigger_status = lttng_trigger_get_owner_uid(
                trigger, &trigger_owner);
@@ -4372,8 +4475,8 @@ enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_c
         * it is safe to use without any locking as its properties are
         * immutable.
         */
-       ret_code = notification_thread_command_register_trigger(notification_thread,
-                       trigger);
+       ret_code = notification_thread_command_register_trigger(
+                       notification_thread, trigger, is_trigger_anonymous);
        if (ret_code != LTTNG_OK) {
                DBG("Failed to register trigger to notification thread: trigger name = '%s', trigger owner uid = %d, error code = %d",
                                trigger_name, (int) trigger_owner, ret_code);
@@ -4382,74 +4485,19 @@ enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_c
 
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
        trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
-                       trigger_name : "(unnamed)";
-
-       ret_code = trigger_modifies_event_notifier(trigger, &must_update_event_notifiers);
-       if (ret_code != LTTNG_OK) {
-               ERR("Failed to determine if event modifies event notifiers: trigger name = '%s', trigger owner uid = %d, error code = %d",
-                               trigger_name, (int) trigger_owner, ret_code);
-               goto end;
-       }
+                       trigger_name : "(anonymous)";
 
        /*
         * Synchronize tracers if the trigger adds an event notifier.
         */
-       if (must_update_event_notifiers) {
-               const enum lttng_domain_type trigger_domain =
-                               lttng_trigger_get_underlying_domain_type_restriction(trigger);
-
-               session_lock_list();
-               switch (trigger_domain) {
-               case LTTNG_DOMAIN_KERNEL:
-               {
-                       ret_code = kernel_register_event_notifier(
-                                       trigger, cmd_creds);
-                       if (ret_code != LTTNG_OK) {
-                               const enum lttng_error_code notif_thread_unregister_ret =
-                                               notification_thread_command_unregister_trigger(
-                                                               notification_thread,
-                                                               trigger);
-
-                               if (notif_thread_unregister_ret != LTTNG_OK) {
-                                       /* Return the original error code. */
-                                       ERR("Failed to unregister trigger from notification thread during error recovery: trigger name = '%s', trigger owner uid = %d, error code = %d",
-                                                       trigger_name,
-                                                       (int) trigger_owner,
-                                                       ret_code);
-                               }
-                       }
-                       break;
-               }
-               case LTTNG_DOMAIN_UST:
-                       ust_app_global_update_all_event_notifier_rules();
-                       break;
-               case LTTNG_DOMAIN_NONE:
-                       abort();
-               default:
-               {
-                       /* Agent domains. */
-                       struct agent *agt = agent_find_by_event_notifier_domain(
-                                       trigger_domain);
-
-                       if (!agt) {
-                               agt = agent_create(trigger_domain);
-                               if (!agt) {
-                                       ret_code = LTTNG_ERR_NOMEM;
-                                       goto end_unlock_session_list;
-                               }
-                               agent_add(agt, trigger_agents_ht_by_domain);
-                       }
-
-                       ret_code = trigger_agent_enable(trigger, agt);
-                       if (ret_code != LTTNG_OK) {
-                               goto end_unlock_session_list;
-                       }
-
-                       break;
-               }
+       if (lttng_trigger_needs_tracer_notifier(trigger)) {
+               ret_code = synchronize_tracer_notifier_register(notification_thread,
+                               trigger, cmd_creds);
+               if (ret_code != LTTNG_OK) {
+                       ERR("Error registering tracer notifier: %s",
+                                       lttng_strerror(-ret_code));
+                       goto end;
                }
-
-               session_unlock_list();
        }
 
        /*
@@ -4467,6 +4515,62 @@ enum lttng_error_code cmd_register_trigger(const struct lttng_credentials *cmd_c
        }
 end:
        return ret_code;
+}
+
+static
+enum lttng_error_code synchronize_tracer_notifier_unregister(
+               const struct lttng_trigger *trigger)
+{
+       enum lttng_error_code ret_code;
+       const struct lttng_condition *condition =
+                       lttng_trigger_get_const_condition(trigger);
+       const enum lttng_domain_type trigger_domain =
+                       lttng_trigger_get_underlying_domain_type_restriction(
+                                       trigger);
+
+       assert(condition);
+       assert(lttng_condition_get_type(condition) ==
+                       LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+
+       session_lock_list();
+       switch (trigger_domain) {
+       case LTTNG_DOMAIN_KERNEL:
+               ret_code = kernel_unregister_event_notifier(trigger);
+               if (ret_code != LTTNG_OK) {
+                       goto end_unlock_session_list;
+               }
+
+               break;
+       case LTTNG_DOMAIN_UST:
+               ust_app_global_update_all_event_notifier_rules();
+               break;
+       case LTTNG_DOMAIN_JUL:
+       case LTTNG_DOMAIN_LOG4J:
+       case LTTNG_DOMAIN_PYTHON:
+       {
+               /* Agent domains. */
+               struct agent *agt = agent_find_by_event_notifier_domain(
+                               trigger_domain);
+
+               /*
+                * This trigger was never registered in the first place. Calling
+                * this function under those circumstances is an internal error.
+                */
+               assert(agt);
+               ret_code = trigger_agent_disable(trigger, agt);
+               if (ret_code != LTTNG_OK) {
+                       goto end_unlock_session_list;
+               }
+
+               break;
+       }
+       case LTTNG_DOMAIN_NONE:
+       default:
+               abort();
+       }
+
+       ret_code = LTTNG_OK;
+
 end_unlock_session_list:
        session_unlock_list();
        return ret_code;
@@ -4477,15 +4581,14 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
                struct notification_thread_handle *notification_thread)
 {
        enum lttng_error_code ret_code;
-       bool must_update_event_notifiers;
        const char *trigger_name;
        uid_t trigger_owner;
        enum lttng_trigger_status trigger_status;
+       struct lttng_trigger *sessiond_trigger = NULL;
 
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
-       trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(unnamed)";
-       trigger_status = lttng_trigger_get_owner_uid(
-               trigger, &trigger_owner);
+       trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(anonymous)";
+       trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_owner);
        assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
 
        DBG("Running unregister trigger command: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
@@ -4509,18 +4612,34 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
                }
        }
 
-       ret_code = trigger_modifies_event_notifier(trigger, &must_update_event_notifiers);
+       /* Fetch the sessiond side trigger object. */
+       ret_code = notification_thread_command_get_trigger(
+                       notification_thread, trigger, &sessiond_trigger);
        if (ret_code != LTTNG_OK) {
-               ERR("Failed to determine if event modifies event notifiers: trigger name = '%s', trigger owner uid = %d, error code = %d",
+               DBG("Failed to get trigger from notification thread during unregister: trigger name = '%s', trigger owner uid = %d, error code = %d",
                                trigger_name, (int) trigger_owner, ret_code);
                goto end;
        }
 
+       assert(sessiond_trigger);
+
+       /*
+        * From this point on, no matter what, consider the trigger
+        * unregistered.
+        *
+        * We set the unregistered state of the sessiond side trigger object in
+        * the client thread since we want to minimize the possibility of the
+        * notification thread being stalled due to a long execution of an
+        * action that required the trigger lock.
+        */
+       lttng_trigger_set_as_unregistered(sessiond_trigger);
+
        ret_code = notification_thread_command_unregister_trigger(notification_thread,
                                                                  trigger);
        if (ret_code != LTTNG_OK) {
                DBG("Failed to unregister trigger from notification thread: trigger name = '%s', trigger owner uid = %d, error code = %d",
                                trigger_name, (int) trigger_owner, ret_code);
+               goto end;
        }
 
        /*
@@ -4529,62 +4648,25 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
         * the tracers from producing notifications associated with this
         * event notifier.
         */
-       if (must_update_event_notifiers) {
-               const enum lttng_domain_type trigger_domain =
-                               lttng_trigger_get_underlying_domain_type_restriction(
-                                               trigger);
-
-               session_lock_list();
-               switch (trigger_domain) {
-               case LTTNG_DOMAIN_KERNEL:
-               {
-                       ret_code = kernel_unregister_event_notifier(
-                                       trigger);
-                       break;
-               }
-               case LTTNG_DOMAIN_UST:
-                       ust_app_global_update_all_event_notifier_rules();
-                       break;
-               case LTTNG_DOMAIN_NONE:
-                       abort();
-               default:
-               {
-                       /* Agent domains. */
-                       struct agent *agt = agent_find_by_event_notifier_domain(
-                                       trigger_domain);
-
-                       if (!agt) {
-                               agt = agent_create(trigger_domain);
-                               if (!agt) {
-                                       ret_code = LTTNG_ERR_NOMEM;
-                                       goto end_unlock_session_list;
-                               }
-                               agent_add(agt, trigger_agents_ht_by_domain);
-                       }
-
-                       ret_code = trigger_agent_disable(trigger, agt);
-                       if (ret_code != LTTNG_OK) {
-                               goto end_unlock_session_list;
-                       }
-
-                       break;
-               }
+       if (lttng_trigger_needs_tracer_notifier(trigger)) {
+               ret_code = synchronize_tracer_notifier_unregister(trigger);
+               if (ret_code != LTTNG_OK) {
+                       ERR("Error unregistering trigger to tracer.");
+                       goto end;
                }
 
-               session_unlock_list();
        }
 
 end:
+       lttng_trigger_put(sessiond_trigger);
        return ret_code;
-end_unlock_session_list:
-       session_unlock_list();
-       return ret_code;}
+}
 
-int cmd_list_triggers(struct command_ctx *cmd_ctx,
+enum lttng_error_code cmd_list_triggers(struct command_ctx *cmd_ctx,
                struct notification_thread_handle *notification_thread,
                struct lttng_triggers **return_triggers)
 {
-       int ret = 0;
+       int ret;
        enum lttng_error_code ret_code;
        struct lttng_triggers *triggers = NULL;
 
@@ -4592,17 +4674,165 @@ int cmd_list_triggers(struct command_ctx *cmd_ctx,
        ret_code = notification_thread_command_list_triggers(
                        notification_thread, cmd_ctx->creds.uid, &triggers);
        if (ret_code != LTTNG_OK) {
-               ret = ret_code;
+               goto end;
+       }
+
+       ret = lttng_triggers_remove_hidden_triggers(triggers);
+       if (ret) {
+               ret_code = LTTNG_ERR_UNK;
                goto end;
        }
 
        *return_triggers = triggers;
        triggers = NULL;
-       ret = LTTNG_OK;
+       ret_code = LTTNG_OK;
 end:
        lttng_triggers_destroy(triggers);
-       return ret;
+       return ret_code;
 }
+
+enum lttng_error_code cmd_execute_error_query(const struct lttng_credentials *cmd_creds,
+               const struct lttng_error_query *query,
+               struct lttng_error_query_results **_results,
+               struct notification_thread_handle *notification_thread)
+{
+       enum lttng_error_code ret_code;
+       const struct lttng_trigger *query_target_trigger;
+       const struct lttng_action *query_target_action = NULL;
+       struct lttng_trigger *matching_trigger = NULL;
+       const char *trigger_name;
+       uid_t trigger_owner;
+       enum lttng_trigger_status trigger_status;
+       struct lttng_error_query_results *results = NULL;
+
+       switch (lttng_error_query_get_target_type(query)) {
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
+               query_target_trigger = lttng_error_query_trigger_borrow_target(query);
+               break;
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
+               query_target_trigger =
+                               lttng_error_query_condition_borrow_target(query);
+               break;
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
+               query_target_trigger = lttng_error_query_action_borrow_trigger_target(
+                               query);
+               break;
+       default:
+               abort();
+       }
+
+       assert(query_target_trigger);
+
+       ret_code = notification_thread_command_get_trigger(notification_thread,
+                       query_target_trigger, &matching_trigger);
+       if (ret_code != LTTNG_OK) {
+               goto end;
+       }
+
+       /* No longer needed. */
+       query_target_trigger = NULL;
+
+       if (lttng_error_query_get_target_type(query) ==
+                       LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION) {
+               /* Get the sessiond-side version of the target action. */
+               query_target_action =
+                               lttng_error_query_action_borrow_action_target(
+                                               query, matching_trigger);
+       }
+
+       trigger_status = lttng_trigger_get_name(matching_trigger, &trigger_name);
+       trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?
+                       trigger_name : "(anonymous)";
+       trigger_status = lttng_trigger_get_owner_uid(matching_trigger,
+                       &trigger_owner);
+       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+       results = lttng_error_query_results_create();
+       if (!results) {
+               ret_code = LTTNG_ERR_NOMEM;
+               goto end;
+       }
+
+       DBG("Running \"execute error query\" command: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
+                       trigger_name, (int) trigger_owner,
+                       (int) lttng_credentials_get_uid(cmd_creds));
+
+       /*
+        * Validate the trigger credentials against the command credentials.
+        * Only the root user can target a trigger with non-matching
+        * credentials.
+        */
+       if (!lttng_credentials_is_equal_uid(
+                       lttng_trigger_get_credentials(matching_trigger),
+                       cmd_creds)) {
+               if (lttng_credentials_get_uid(cmd_creds) != 0) {
+                       ERR("Trigger credentials do not match the command credentials: trigger name = '%s', trigger owner uid = %d, command creds uid = %d",
+                                       trigger_name, (int) trigger_owner,
+                                       (int) lttng_credentials_get_uid(cmd_creds));
+                       ret_code = LTTNG_ERR_INVALID_TRIGGER;
+                       goto end;
+               }
+       }
+
+       switch (lttng_error_query_get_target_type(query)) {
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER:
+               trigger_status = lttng_trigger_add_error_results(
+                               matching_trigger, results);
+
+               switch (trigger_status) {
+               case LTTNG_TRIGGER_STATUS_OK:
+                       break;
+               default:
+                       ret_code = LTTNG_ERR_UNK;
+                       goto end;
+               }
+
+               break;
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION:
+       {
+               trigger_status = lttng_trigger_condition_add_error_results(
+                               matching_trigger, results);
+
+               switch (trigger_status) {
+               case LTTNG_TRIGGER_STATUS_OK:
+                       break;
+               default:
+                       ret_code = LTTNG_ERR_UNK;
+                       goto end;
+               }
+
+               break;
+       }
+       case LTTNG_ERROR_QUERY_TARGET_TYPE_ACTION:
+       {
+               const enum lttng_action_status action_status =
+                               lttng_action_add_error_query_results(
+                                               query_target_action, results);
+
+               switch (action_status) {
+               case LTTNG_ACTION_STATUS_OK:
+                       break;
+               default:
+                       ret_code = LTTNG_ERR_UNK;
+                       goto end;
+               }
+
+               break;
+       }
+       default:
+               abort();
+               break;
+       }
+
+       *_results = results;
+       results = NULL;
+       ret_code = LTTNG_OK;
+end:
+       lttng_trigger_put(matching_trigger);
+       lttng_error_query_results_destroy(results);
+       return ret_code;
+}
+
 /*
  * Send relayd sockets from snapshot output to consumer. Ignore request if the
  * snapshot output is *not* set with a remote destination.
@@ -4853,6 +5083,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                consumer_copy_output(snapshot_output->consumer);
                strcpy(snapshot_kernel_consumer_output->chunk_path,
                        snapshot_chunk_name);
+
+               /* Copy the original domain subdir. */
+               strcpy(snapshot_kernel_consumer_output->domain_subdir,
+                               original_kernel_consumer_output->domain_subdir);
+
                ret = consumer_copy_sockets(snapshot_kernel_consumer_output,
                                original_kernel_consumer_output);
                if (ret < 0) {
@@ -4875,6 +5110,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                consumer_copy_output(snapshot_output->consumer);
                strcpy(snapshot_ust_consumer_output->chunk_path,
                        snapshot_chunk_name);
+
+               /* Copy the original domain subdir. */
+               strcpy(snapshot_ust_consumer_output->domain_subdir,
+                               original_ust_consumer_output->domain_subdir);
+
                ret = consumer_copy_sockets(snapshot_ust_consumer_output,
                                original_ust_consumer_output);
                if (ret < 0) {
@@ -4957,6 +5197,9 @@ error_close_trace_chunk:
                                session->name);
                ret_code = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
        }
+
+       lttng_trace_chunk_put(snapshot_trace_chunk);
+       snapshot_trace_chunk = NULL;
 error:
        if (original_ust_consumer_output) {
                session->ust_session->consumer = original_ust_consumer_output;
@@ -5297,8 +5540,8 @@ int cmd_rotate_session(struct ltt_session *session,
        chunk_being_archived = NULL;
        if (!quiet_rotation) {
                ret = notification_thread_command_session_rotation_ongoing(
-                               notification_thread_handle,
-                               session->name, session->uid, session->gid,
+                               the_notification_thread_handle, session->name,
+                               session->uid, session->gid,
                                ongoing_rotation_chunk_id);
                if (ret != LTTNG_OK) {
                        ERR("Failed to notify notification thread that a session rotation is ongoing for session %s",
This page took 0.03949 seconds and 4 git commands to generate.