X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-app.cpp;h=b4192398b1682b01e4779df80f05945c7b1627eb;hb=84083c3c07b8c1f6320963c395d9c4a9012cdb44;hp=54cd4dea645b7e1b30edf06822156bdc3781ed37;hpb=fb2772932d3207bd9d340f34f41d822d9c0ff0a9;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 54cd4dea6..b4192398b 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * Copyright (C) 2016 Jérémie Galarneau * * SPDX-License-Identifier: GPL-2.0-only @@ -21,35 +21,35 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include +#include #include #include -#include +#include #include -#include -#include - -#include "buffer-registry.h" -#include "condition-internal.h" -#include "fd-limit.h" -#include "health-sessiond.h" -#include "ust-app.h" -#include "ust-consumer.h" -#include "lttng-ust-ctl.h" -#include "lttng-ust-error.h" -#include "utils.h" -#include "session.h" -#include "lttng-sessiond.h" -#include "notification-thread-commands.h" -#include "rotate.h" -#include "event.h" -#include "event-notifier-error-accounting.h" -#include "ust-field-utils.h" +#include +#include + +#include "buffer-registry.hpp" +#include "condition-internal.hpp" +#include "fd-limit.hpp" +#include "health-sessiond.hpp" +#include "ust-app.hpp" +#include "ust-consumer.hpp" +#include "lttng-ust-ctl.hpp" +#include "lttng-ust-error.hpp" +#include "utils.hpp" +#include "session.hpp" +#include "lttng-sessiond.hpp" +#include "notification-thread-commands.hpp" +#include "rotate.hpp" +#include "event.hpp" +#include "event-notifier-error-accounting.hpp" +#include "ust-field-utils.hpp" struct lttng_ht *ust_app_ht; struct lttng_ht *ust_app_ht_by_sock; @@ -240,10 +240,10 @@ static void close_notify_sock_rcu(struct rcu_head *head) * A registry per UID object MUST exists before calling this function or else * it LTTNG_ASSERT() if not found. RCU read side lock must be acquired. */ -static struct ust_registry_session *get_session_registry( +static ust_registry_session *get_session_registry( struct ust_app_session *ua_sess) { - struct ust_registry_session *registry = NULL; + ust_registry_session *registry = NULL; LTTNG_ASSERT(ua_sess); @@ -287,6 +287,7 @@ void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx, int ret; LTTNG_ASSERT(ua_ctx); + ASSERT_RCU_READ_LOCKED(); if (ua_ctx->obj) { pthread_mutex_lock(&app->sock_lock); @@ -321,6 +322,7 @@ void delete_ust_app_event(int sock, struct ust_app_event *ua_event, int ret; LTTNG_ASSERT(ua_event); + ASSERT_RCU_READ_LOCKED(); free(ua_event->filter); if (ua_event->exclusion != NULL) @@ -443,25 +445,20 @@ void delete_ust_app_stream(int sock, struct ust_app_stream *stream, struct ust_app *app) { LTTNG_ASSERT(stream); + ASSERT_RCU_READ_LOCKED(); (void) release_ust_app_stream(sock, stream, app); free(stream); } -/* - * We need to execute ht_destroy outside of RCU read-side critical - * section and outside of call_rcu thread, so we postpone its execution - * using ht_cleanup_push. It is simpler than to change the semantic of - * the many callers of delete_ust_app_session(). - */ static void delete_ust_app_channel_rcu(struct rcu_head *head) { struct ust_app_channel *ua_chan = caa_container_of(head, struct ust_app_channel, rcu_head); - ht_cleanup_push(ua_chan->ctx); - ht_cleanup_push(ua_chan->events); + lttng_ht_destroy(ua_chan->ctx); + lttng_ht_destroy(ua_chan->events); free(ua_chan); } @@ -546,9 +543,10 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan, struct ust_app_event *ua_event; struct ust_app_ctx *ua_ctx; struct ust_app_stream *stream, *stmp; - struct ust_registry_session *registry; + ust_registry_session *registry; LTTNG_ASSERT(ua_chan); + ASSERT_RCU_READ_LOCKED(); DBG3("UST app deleting channel %s", ua_chan->name); @@ -659,7 +657,7 @@ int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data * but it can be caused by recoverable errors (e.g. the application has * terminated concurrently). */ -ssize_t ust_app_push_metadata(struct ust_registry_session *registry, +ssize_t ust_app_push_metadata(ust_registry_session *registry, struct consumer_socket *socket, int send_zero_data) { int ret; @@ -670,8 +668,9 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry, LTTNG_ASSERT(registry); LTTNG_ASSERT(socket); + ASSERT_RCU_READ_LOCKED(); - metadata_key = registry->metadata_key; + metadata_key = registry->_metadata_key; /* * Means that no metadata was assigned to the session. This can @@ -681,13 +680,13 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry, return 0; } - offset = registry->metadata_len_sent; - len = registry->metadata_len - registry->metadata_len_sent; - new_metadata_len_sent = registry->metadata_len; - metadata_version = registry->metadata_version; + offset = registry->_metadata_len_sent; + len = registry->_metadata_len - registry->_metadata_len_sent; + new_metadata_len_sent = registry->_metadata_len; + metadata_version = registry->_metadata_version; if (len == 0) { DBG3("No metadata to push for metadata key %" PRIu64, - registry->metadata_key); + registry->_metadata_key); ret_val = len; if (send_zero_data) { DBG("No metadata to push"); @@ -697,17 +696,17 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry, } /* Allocate only what we have to send. */ - metadata_str = (char *) zmalloc(len); + metadata_str = calloc(len); if (!metadata_str) { PERROR("zmalloc ust app metadata string"); ret_val = -ENOMEM; goto error; } /* Copy what we haven't sent out. */ - memcpy(metadata_str, registry->metadata + offset, len); + memcpy(metadata_str, registry->_metadata + offset, len); push_data: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); /* * We need to unlock the registry while we push metadata to * break a circular dependency between the consumerd metadata @@ -722,7 +721,7 @@ push_data: */ ret = consumer_push_metadata(socket, metadata_key, metadata_str, len, offset, metadata_version); - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); if (ret < 0) { /* * There is an acceptable race here between the registry @@ -759,8 +758,8 @@ push_data: * largest metadata_len_sent value of the concurrent * send. */ - registry->metadata_len_sent = - std::max(registry->metadata_len_sent, + registry->_metadata_len_sent = + std::max(registry->_metadata_len_sent, new_metadata_len_sent); } free(metadata_str); @@ -776,7 +775,7 @@ error: * the metadata cache has been destroyed on the * consumer. */ - registry->metadata_closed = 1; + registry->_metadata_closed = true; } error_push: free(metadata_str); @@ -797,7 +796,7 @@ error_push: * but it can be caused by recoverable errors (e.g. the application has * terminated concurrently). */ -static int push_metadata(struct ust_registry_session *registry, +static int push_metadata(ust_registry_session *registry, struct consumer_output *consumer) { int ret_val; @@ -806,15 +805,16 @@ static int push_metadata(struct ust_registry_session *registry, LTTNG_ASSERT(registry); LTTNG_ASSERT(consumer); + ASSERT_RCU_READ_LOCKED(); - pthread_mutex_lock(®istry->lock); - if (registry->metadata_closed) { + pthread_mutex_lock(®istry->_lock); + if (registry->_metadata_closed) { ret_val = -EPIPE; goto error; } /* Get consumer socket to use to push the metadata.*/ - socket = consumer_find_socket_by_bitness(registry->bits_per_long, + socket = consumer_find_socket_by_bitness(registry->_bits_per_long, consumer); if (!socket) { ret_val = -1; @@ -826,11 +826,11 @@ static int push_metadata(struct ust_registry_session *registry, ret_val = ret; goto error; } - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); return 0; error: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); return ret_val; } @@ -846,7 +846,7 @@ error: * * Return 0 on success else a negative value. */ -static int close_metadata(struct ust_registry_session *registry, +static int close_metadata(ust_registry_session *registry, struct consumer_output *consumer) { int ret; @@ -859,18 +859,18 @@ static int close_metadata(struct ust_registry_session *registry, rcu_read_lock(); - pthread_mutex_lock(®istry->lock); - metadata_key = registry->metadata_key; - registry_was_already_closed = registry->metadata_closed; + pthread_mutex_lock(®istry->_lock); + metadata_key = registry->_metadata_key; + registry_was_already_closed = registry->_metadata_closed; if (metadata_key != 0) { /* * Metadata closed. Even on error this means that the consumer * is not responding or not found so either way a second close * should NOT be emit for this registry. */ - registry->metadata_closed = 1; + registry->_metadata_closed = true; } - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); if (metadata_key == 0 || registry_was_already_closed) { ret = 0; @@ -878,7 +878,7 @@ static int close_metadata(struct ust_registry_session *registry, } /* Get consumer socket to use to push the metadata.*/ - socket = consumer_find_socket_by_bitness(registry->bits_per_long, + socket = consumer_find_socket_by_bitness(registry->_bits_per_long, consumer); if (!socket) { ret = -1; @@ -895,19 +895,13 @@ end: return ret; } -/* - * We need to execute ht_destroy outside of RCU read-side critical - * section and outside of call_rcu thread, so we postpone its execution - * using ht_cleanup_push. It is simpler than to change the semantic of - * the many callers of delete_ust_app_session(). - */ static void delete_ust_app_session_rcu(struct rcu_head *head) { struct ust_app_session *ua_sess = caa_container_of(head, struct ust_app_session, rcu_head); - ht_cleanup_push(ua_sess->channels); + lttng_ht_destroy(ua_sess->channels); free(ua_sess); } @@ -924,9 +918,10 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, int ret; struct lttng_ht_iter iter; struct ust_app_channel *ua_chan; - struct ust_registry_session *registry; + ust_registry_session *registry; LTTNG_ASSERT(ua_sess); + ASSERT_RCU_READ_LOCKED(); pthread_mutex_lock(&ua_sess->lock); @@ -1004,8 +999,6 @@ void delete_ust_app_session(int sock, struct ust_app_session *ua_sess, /* * Delete a traceable application structure from the global list. Never call * this function outside of a call_rcu call. - * - * RCU read side lock should _NOT_ be held when calling this function. */ static void delete_ust_app(struct ust_app *app) @@ -1047,10 +1040,10 @@ void delete_ust_app(struct ust_app *app) rcu_read_unlock(); - ht_cleanup_push(app->sessions); - ht_cleanup_push(app->ust_sessions_objd); - ht_cleanup_push(app->ust_objd); - ht_cleanup_push(app->token_to_event_notifier_rule_ht); + lttng_ht_destroy(app->sessions); + lttng_ht_destroy(app->ust_sessions_objd); + lttng_ht_destroy(app->ust_objd); + lttng_ht_destroy(app->token_to_event_notifier_rule_ht); /* * This could be NULL if the event notifier setup failed (e.g the app @@ -1167,7 +1160,7 @@ struct ust_app_session *alloc_ust_app_session(void) struct ust_app_session *ua_sess; /* Init most of the default value by allocating and zeroing */ - ua_sess = (ust_app_session *) zmalloc(sizeof(struct ust_app_session)); + ua_sess = zmalloc(); if (ua_sess == NULL) { PERROR("malloc"); goto error_free; @@ -1195,7 +1188,7 @@ struct ust_app_channel *alloc_ust_app_channel(const char *name, struct ust_app_channel *ua_chan; /* Init most of the default value by allocating and zeroing */ - ua_chan = (ust_app_channel *) zmalloc(sizeof(struct ust_app_channel)); + ua_chan = zmalloc(); if (ua_chan == NULL) { PERROR("malloc"); goto error; @@ -1247,7 +1240,7 @@ struct ust_app_stream *ust_app_alloc_stream(void) { struct ust_app_stream *stream = NULL; - stream = (ust_app_stream *) zmalloc(sizeof(*stream)); + stream = zmalloc(); if (stream == NULL) { PERROR("zmalloc ust app stream"); goto error; @@ -1270,7 +1263,7 @@ struct ust_app_event *alloc_ust_app_event(char *name, struct ust_app_event *ua_event; /* Init most of the default value by allocating and zeroing */ - ua_event = (ust_app_event *) zmalloc(sizeof(struct ust_app_event)); + ua_event = zmalloc(); if (ua_event == NULL) { PERROR("Failed to allocate ust_app_event structure"); goto error; @@ -1307,7 +1300,7 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule( struct lttng_condition *condition = NULL; const struct lttng_event_rule *event_rule = NULL; - ua_event_notifier_rule = (ust_app_event_notifier_rule *) zmalloc(sizeof(struct ust_app_event_notifier_rule)); + ua_event_notifier_rule = zmalloc(); if (ua_event_notifier_rule == NULL) { PERROR("Failed to allocate ust_app_event_notifier_rule structure"); goto error; @@ -1367,7 +1360,7 @@ struct ust_app_ctx *alloc_ust_app_ctx(struct lttng_ust_context_attr *uctx) { struct ust_app_ctx *ua_ctx; - ua_ctx = (ust_app_ctx *) zmalloc(sizeof(struct ust_app_ctx)); + ua_ctx = zmalloc(); if (ua_ctx == NULL) { goto error; } @@ -1410,7 +1403,7 @@ static struct lttng_ust_abi_filter_bytecode *create_ust_filter_bytecode_from_byt struct lttng_ust_abi_filter_bytecode *filter = NULL; /* Copy filter bytecode. */ - filter = (lttng_ust_abi_filter_bytecode *) zmalloc(sizeof(*filter) + orig_f->len); + filter = zmalloc(sizeof(*filter) + orig_f->len); if (!filter) { PERROR("Failed to allocate lttng_ust_filter_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len); goto error; @@ -1434,7 +1427,7 @@ create_ust_capture_bytecode_from_bytecode(const struct lttng_bytecode *orig_f) struct lttng_ust_abi_capture_bytecode *capture = NULL; /* Copy capture bytecode. */ - capture = (lttng_ust_abi_capture_bytecode *) zmalloc(sizeof(*capture) + orig_f->len); + capture = zmalloc(sizeof(*capture) + orig_f->len); if (!capture) { PERROR("Failed to allocate lttng_ust_abi_capture_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len); goto error; @@ -1456,6 +1449,8 @@ struct ust_app *ust_app_find_by_sock(int sock) struct lttng_ht_node_ulong *node; struct lttng_ht_iter iter; + ASSERT_RCU_READ_LOCKED(); + lttng_ht_lookup(ust_app_ht_by_sock, (void *)((unsigned long) sock), &iter); node = lttng_ht_iter_get_node_ulong(&iter); if (node == NULL) { @@ -1478,6 +1473,8 @@ static struct ust_app *find_app_by_notify_sock(int sock) struct lttng_ht_node_ulong *node; struct lttng_ht_iter iter; + ASSERT_RCU_READ_LOCKED(); + lttng_ht_lookup(ust_app_ht_by_notify_sock, (void *)((unsigned long) sock), &iter); node = lttng_ht_iter_get_node_ulong(&iter); @@ -1546,6 +1543,7 @@ static struct ust_app_event_notifier_rule *find_ust_app_event_notifier_rule( struct ust_app_event_notifier_rule *event_notifier_rule = NULL; LTTNG_ASSERT(ht); + ASSERT_RCU_READ_LOCKED(); lttng_ht_lookup(ht, &token, &iter); node = lttng_ht_iter_get_node_u64(&iter); @@ -1713,7 +1711,7 @@ struct lttng_ust_abi_event_exclusion *create_ust_exclusion_from_exclusion( size_t exclusion_alloc_size = sizeof(struct lttng_ust_abi_event_exclusion) + LTTNG_UST_ABI_SYM_NAME_LEN * exclusion->count; - ust_exclusion = (lttng_ust_abi_event_exclusion *) zmalloc(exclusion_alloc_size); + ust_exclusion = zmalloc(exclusion_alloc_size); if (!ust_exclusion) { PERROR("malloc"); goto end; @@ -1986,8 +1984,6 @@ static int send_channel_pid_to_ust(struct ust_app *app, cds_list_del(&stream->list); delete_ust_app_stream(-1, stream, app); } - /* Flag the channel that it is sent to the application. */ - ua_chan->is_sent = 1; error: health_code_update(); @@ -2000,7 +1996,7 @@ error: * Should be called with session mutex held. */ static -int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess, +int create_ust_event(struct ust_app *app, struct ust_app_channel *ua_chan, struct ust_app_event *ua_event) { int ret = 0; @@ -2151,7 +2147,7 @@ static int init_ust_event_notifier_from_event_rule( event_notifier->event.instrumentation = LTTNG_UST_ABI_TRACEPOINT; ret = lttng_strncpy(event_notifier->event.name, pattern, - LTTNG_UST_ABI_SYM_NAME_LEN - 1); + sizeof(event_notifier->event.name)); if (ret) { ERR("Failed to copy event rule pattern to notifier: pattern = '%s' ", pattern); @@ -2333,7 +2329,7 @@ static void shadow_copy_event(struct ust_app_event *ua_event, if (uevent->exclusion) { exclusion_alloc_size = sizeof(struct lttng_event_exclusion) + LTTNG_UST_ABI_SYM_NAME_LEN * uevent->exclusion->count; - ua_event->exclusion = (lttng_event_exclusion *) zmalloc(exclusion_alloc_size); + ua_event->exclusion = zmalloc(exclusion_alloc_size); if (ua_event->exclusion == NULL) { PERROR("malloc"); } else { @@ -2538,7 +2534,7 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess, } /* Initialize registry. */ - ret = ust_registry_session_init(®_pid->registry->reg.ust, app, + reg_pid->registry->reg.ust = ust_registry_session_per_pid_create(app, app->bits_per_long, app->uint8_t_alignment, app->uint16_t_alignment, app->uint32_t_alignment, app->uint64_t_alignment, app->long_alignment, @@ -2546,9 +2542,8 @@ static int setup_buffer_reg_pid(struct ust_app_session *ua_sess, reg_pid->root_shm_path, reg_pid->shm_path, lttng_credentials_get_uid(&ua_sess->effective_credentials), lttng_credentials_get_gid(&ua_sess->effective_credentials), - ua_sess->tracing_id, - app->uid); - if (ret < 0) { + ua_sess->tracing_id); + if (!reg_pid->registry->reg.ust) { /* * reg_pid->registry->reg.ust is NULL upon error, so we need to * destroy the buffer registry, because it is always expected @@ -2608,7 +2603,7 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, } /* Initialize registry. */ - ret = ust_registry_session_init(®_uid->registry->reg.ust, NULL, + reg_uid->registry->reg.ust = ust_registry_session_per_uid_create( app->bits_per_long, app->uint8_t_alignment, app->uint16_t_alignment, app->uint32_t_alignment, app->uint64_t_alignment, app->long_alignment, @@ -2616,7 +2611,7 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, app->version.minor, reg_uid->root_shm_path, reg_uid->shm_path, usess->uid, usess->gid, ua_sess->tracing_id, app->uid); - if (ret < 0) { + if (!reg_uid->registry->reg.ust) { /* * reg_uid->registry->reg.ust is NULL upon error, so we need to * destroy the buffer registry, because it is always expected @@ -2626,6 +2621,7 @@ static int setup_buffer_reg_uid(struct ltt_ust_session *usess, buffer_reg_uid_destroy(reg_uid, NULL); goto error; } + /* Add node to teardown list of the session. */ cds_list_add(®_uid->lnode, &usess->buffer_reg_uid_list); @@ -2823,6 +2819,7 @@ struct ust_app_ctx *find_ust_app_context(struct lttng_ht *ht, LTTNG_ASSERT(uctx); LTTNG_ASSERT(ht); + ASSERT_RCU_READ_LOCKED(); /* Lookup using the lttng_ust_context_type and a custom match fct. */ cds_lfht_lookup(ht->ht, ht->hash_fct((void *) uctx->ctx, lttng_ht_seed), @@ -2851,6 +2848,8 @@ int create_ust_app_channel_context(struct ust_app_channel *ua_chan, int ret = 0; struct ust_app_ctx *ua_ctx; + ASSERT_RCU_READ_LOCKED(); + DBG2("UST app adding context to channel %s", ua_chan->name); ua_ctx = find_ust_app_context(ua_chan->ctx, uctx); @@ -2885,8 +2884,8 @@ error: * Called with UST app session lock held. */ static -int enable_ust_app_event(struct ust_app_session *ua_sess, - struct ust_app_event *ua_event, struct ust_app *app) +int enable_ust_app_event(struct ust_app_event *ua_event, + struct ust_app *app) { int ret; @@ -2904,8 +2903,8 @@ error: /* * Disable on the tracer side a ust app event for the session and channel. */ -static int disable_ust_app_event(struct ust_app_session *ua_sess, - struct ust_app_event *ua_event, struct ust_app *app) +static int disable_ust_app_event(struct ust_app_event *ua_event, + struct ust_app *app) { int ret; @@ -2952,6 +2951,8 @@ static int enable_ust_app_channel(struct ust_app_session *ua_sess, struct lttng_ht_node_str *ua_chan_node; struct ust_app_channel *ua_chan; + ASSERT_RCU_READ_LOCKED(); + lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter); ua_chan_node = lttng_ht_iter_get_node_str(&iter); if (ua_chan_node == NULL) { @@ -2980,8 +2981,7 @@ error: */ static int do_consumer_create_channel(struct ltt_ust_session *usess, struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan, - int bitness, struct ust_registry_session *registry, - uint64_t trace_archive_id) + int bitness, ust_registry_session *registry) { int ret; unsigned int nb_fd = 0; @@ -3317,7 +3317,7 @@ static int send_channel_uid_to_ust(struct buffer_reg_channel *buf_reg_chan, /* Send all streams to application. */ pthread_mutex_lock(&buf_reg_chan->stream_list_lock); cds_list_for_each_entry(reg_stream, &buf_reg_chan->streams, lnode) { - struct ust_app_stream stream; + struct ust_app_stream stream = {}; ret = duplicate_stream_object(reg_stream, &stream); if (ret < 0) { @@ -3334,8 +3334,8 @@ static int send_channel_uid_to_ust(struct buffer_reg_channel *buf_reg_chan, * Treat this the same way as an application * that is exiting. */ - WARN("Communication with application %d timed out on send_stream for stream \"%s\" of channel \"%s\" of session \"%" PRIu64 "\".", - app->pid, stream.name, + WARN("Communication with application %d timed out on send_stream for stream of channel \"%s\" of session \"%" PRIu64 "\".", + app->pid, ua_chan->name, ua_sess->tracing_id); ret = -ENOTCONN; @@ -3350,7 +3350,6 @@ static int send_channel_uid_to_ust(struct buffer_reg_channel *buf_reg_chan, */ (void) release_ust_app_stream(-1, &stream, app); } - ua_chan->is_sent = 1; error_stream_unlock: pthread_mutex_unlock(&buf_reg_chan->stream_list_lock); @@ -3381,6 +3380,7 @@ static int create_channel_per_uid(struct ust_app *app, LTTNG_ASSERT(usess); LTTNG_ASSERT(ua_sess); LTTNG_ASSERT(ua_chan); + ASSERT_RCU_READ_LOCKED(); DBG("UST app creating channel %s with per UID buffers", ua_chan->name); @@ -3408,16 +3408,15 @@ static int create_channel_per_uid(struct ust_app *app, session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* * Create the buffers on the consumer side. This call populates the * ust app channel object with all streams and data object. */ ret = do_consumer_create_channel(usess, ua_sess, ua_chan, - app->bits_per_long, reg_uid->registry->reg.ust, - session->most_recent_chunk_id.value); + app->bits_per_long, reg_uid->registry->reg.ust); if (ret < 0) { ERR("Error creating UST channel \"%s\" on the consumer daemon", ua_chan->name); @@ -3444,13 +3443,13 @@ static int create_channel_per_uid(struct ust_app *app, } /* Notify the notification subsystem of the channel's creation. */ - pthread_mutex_lock(®_uid->registry->reg.ust->lock); + pthread_mutex_lock(®_uid->registry->reg.ust->_lock); ust_reg_chan = ust_registry_channel_find(reg_uid->registry->reg.ust, ua_chan->tracing_channel_id); LTTNG_ASSERT(ust_reg_chan); ust_reg_chan->consumer_key = ua_chan->key; ust_reg_chan = NULL; - pthread_mutex_unlock(®_uid->registry->reg.ust->lock); + pthread_mutex_unlock(®_uid->registry->reg.ust->_lock); notification_ret = notification_thread_command_add_channel( the_notification_thread_handle, session->name, @@ -3496,7 +3495,7 @@ static int create_channel_per_pid(struct ust_app *app, struct ust_app_channel *ua_chan) { int ret; - struct ust_registry_session *registry; + ust_registry_session *registry; enum lttng_error_code cmd_ret; struct ltt_session *session = NULL; uint64_t chan_reg_key; @@ -3525,14 +3524,12 @@ static int create_channel_per_pid(struct ust_app *app, session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* Create and get channel on the consumer side. */ ret = do_consumer_create_channel(usess, ua_sess, ua_chan, - app->bits_per_long, registry, - session->most_recent_chunk_id.value); + app->bits_per_long, registry); if (ret < 0) { ERR("Error creating UST channel \"%s\" on the consumer daemon", ua_chan->name); @@ -3548,11 +3545,11 @@ static int create_channel_per_pid(struct ust_app *app, } chan_reg_key = ua_chan->key; - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); ust_reg_chan = ust_registry_channel_find(registry, chan_reg_key); LTTNG_ASSERT(ust_reg_chan); ust_reg_chan->consumer_key = ua_chan->key; - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); cmd_ret = notification_thread_command_add_channel( the_notification_thread_handle, session->name, @@ -3601,6 +3598,7 @@ static int ust_app_channel_send(struct ust_app *app, LTTNG_ASSERT(usess->active); LTTNG_ASSERT(ua_sess); LTTNG_ASSERT(ua_chan); + ASSERT_RCU_READ_LOCKED(); /* Handle buffer type before sending the channel to the application. */ switch (usess->buffer_type) { @@ -3651,7 +3649,8 @@ error: */ static int ust_app_channel_allocate(struct ust_app_session *ua_sess, struct ltt_ust_channel *uchan, - enum lttng_ust_abi_chan_type type, struct ltt_ust_session *usess, + enum lttng_ust_abi_chan_type type, + struct ltt_ust_session *usess __attribute__((unused)), struct ust_app_channel **ua_chanp) { int ret = 0; @@ -3659,6 +3658,8 @@ static int ust_app_channel_allocate(struct ust_app_session *ua_sess, struct lttng_ht_node_str *ua_chan_node; struct ust_app_channel *ua_chan; + ASSERT_RCU_READ_LOCKED(); + /* Lookup channel in the ust app session */ lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter); ua_chan_node = lttng_ht_iter_get_node_str(&iter); @@ -3699,13 +3700,15 @@ error: * Called with ust app session mutex held. */ static -int create_ust_app_event(struct ust_app_session *ua_sess, - struct ust_app_channel *ua_chan, struct ltt_ust_event *uevent, +int create_ust_app_event(struct ust_app_channel *ua_chan, + struct ltt_ust_event *uevent, struct ust_app *app) { int ret = 0; struct ust_app_event *ua_event; + ASSERT_RCU_READ_LOCKED(); + ua_event = alloc_ust_app_event(uevent->attr.name, &uevent->attr); if (ua_event == NULL) { /* Only failure mode of alloc_ust_app_event(). */ @@ -3715,7 +3718,7 @@ int create_ust_app_event(struct ust_app_session *ua_sess, shadow_copy_event(ua_event, uevent); /* Create it on the tracer side */ - ret = create_ust_event(app, ua_sess, ua_chan, ua_event); + ret = create_ust_event(app, ua_chan, ua_event); if (ret < 0) { /* * Not found previously means that it does not exist on the @@ -3760,6 +3763,8 @@ int create_ust_app_event_notifier_rule(struct lttng_trigger *trigger, int ret = 0; struct ust_app_event_notifier_rule *ua_event_notifier_rule; + ASSERT_RCU_READ_LOCKED(); + ua_event_notifier_rule = alloc_ust_app_event_notifier_rule(trigger); if (ua_event_notifier_rule == NULL) { ret = -ENOMEM; @@ -3811,21 +3816,22 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, int ret = 0; struct ust_app_channel *metadata; struct consumer_socket *socket; - struct ust_registry_session *registry; + ust_registry_session *registry; struct ltt_session *session = NULL; LTTNG_ASSERT(ua_sess); LTTNG_ASSERT(app); LTTNG_ASSERT(consumer); + ASSERT_RCU_READ_LOCKED(); registry = get_session_registry(ua_sess); /* The UST app session is held registry shall not be null. */ LTTNG_ASSERT(registry); - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); /* Metadata already exists for this registry or it was closed previously */ - if (registry->metadata_key || registry->metadata_closed) { + if (registry->_metadata_key || registry->_metadata_closed) { ret = 0; goto error; } @@ -3860,13 +3866,12 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, * consumer requesting the metadata and the ask_channel call on our side * did not returned yet. */ - registry->metadata_key = metadata->key; + registry->_metadata_key = metadata->key; session = session_find_by_id(ua_sess->tracing_id); LTTNG_ASSERT(session); - - LTTNG_ASSERT(pthread_mutex_trylock(&session->lock)); - LTTNG_ASSERT(session_trylock_list()); + ASSERT_LOCKED(session->lock); + ASSERT_SESSION_LIST_LOCKED(); /* * Ask the metadata channel creation to the consumer. The metadata object @@ -3878,7 +3883,7 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, registry, session->current_trace_chunk); if (ret < 0) { /* Nullify the metadata key so we don't try to close it later on. */ - registry->metadata_key = 0; + registry->_metadata_key = 0; goto error_consumer; } @@ -3891,7 +3896,7 @@ static int create_ust_app_metadata(struct ust_app_session *ua_sess, ret = consumer_setup_metadata(socket, metadata->key); if (ret < 0) { /* Nullify the metadata key so we don't try to close it later on. */ - registry->metadata_key = 0; + registry->_metadata_key = 0; goto error_consumer; } @@ -3902,7 +3907,7 @@ error_consumer: lttng_fd_put(LTTNG_FD_APPS, 1); delete_ust_app_channel(-1, metadata, app); error: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); if (session) { session_put(session); } @@ -3983,7 +3988,7 @@ struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock) goto error; } - lta = (ust_app *) zmalloc(sizeof(struct ust_app)); + lta = zmalloc(); if (lta == NULL) { PERROR("malloc"); goto error_free_pipe; @@ -4260,7 +4265,7 @@ void ust_app_unregister(int sock) */ cds_lfht_for_each_entry(lta->sessions->ht, &iter.iter, ua_sess, node.node) { - struct ust_registry_session *registry; + ust_registry_session *registry; ret = lttng_ht_del(lta->sessions, &iter); if (ret) { @@ -4359,7 +4364,7 @@ int ust_app_list_events(struct lttng_event **events) struct lttng_event *tmp_event; nbmem = UST_APP_EVENT_LIST_SIZE; - tmp_event = (lttng_event *) zmalloc(nbmem * sizeof(struct lttng_event)); + tmp_event = calloc(nbmem); if (tmp_event == NULL) { PERROR("zmalloc ust app events"); ret = -ENOMEM; @@ -4494,7 +4499,7 @@ int ust_app_list_event_fields(struct lttng_event_field **fields) struct lttng_event_field *tmp_event; nbmem = UST_APP_EVENT_LIST_SIZE; - tmp_event = (lttng_event_field *) zmalloc(nbmem * sizeof(struct lttng_event_field)); + tmp_event = calloc(nbmem); if (tmp_event == NULL) { PERROR("zmalloc ust app event fields"); ret = -ENOMEM; @@ -4618,8 +4623,6 @@ error: /* * Free and clean all traceable apps of the global list. - * - * Should _NOT_ be called with RCU read-side lock held. */ void ust_app_clean_list(void) { @@ -4666,13 +4669,13 @@ void ust_app_clean_list(void) /* Destroy is done only when the ht is empty */ if (ust_app_ht) { - ht_cleanup_push(ust_app_ht); + lttng_ht_destroy(ust_app_ht); } if (ust_app_ht_by_sock) { - ht_cleanup_push(ust_app_ht_by_sock); + lttng_ht_destroy(ust_app_ht_by_sock); } if (ust_app_ht_by_notify_sock) { - ht_cleanup_push(ust_app_ht_by_notify_sock); + lttng_ht_destroy(ust_app_ht_by_notify_sock); } } @@ -4850,7 +4853,7 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess, continue; } - ret = disable_ust_app_event(ua_sess, ua_event, app); + ret = disable_ust_app_event(ua_event, app); if (ret < 0) { /* XXX: Report error someday... */ continue; @@ -5009,7 +5012,7 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess, goto next_app; } - ret = enable_ust_app_event(ua_sess, ua_event, app); + ret = enable_ust_app_event(ua_event, app); if (ret < 0) { pthread_mutex_unlock(&ua_sess->lock); goto error; @@ -5073,7 +5076,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess, ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); - ret = create_ust_app_event(ua_sess, ua_chan, uevent, app); + ret = create_ust_app_event(ua_chan, uevent, app); pthread_mutex_unlock(&ua_sess->lock); if (ret < 0) { if (ret != -LTTNG_UST_ERR_EXIST) { @@ -5204,7 +5207,7 @@ int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app) { int ret = 0; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; DBG("Stopping tracing for ust app pid %d", app->pid); @@ -5386,7 +5389,7 @@ int ust_app_flush_session(struct ltt_ust_session *usess) /* Flush all per UID buffers associated to that session. */ cds_list_for_each_entry(reg, &usess->buffer_reg_uid_list, lnode) { - struct ust_registry_session *ust_session_reg; + ust_registry_session *ust_session_reg; struct buffer_reg_channel *buf_reg_chan; struct consumer_socket *socket; @@ -5769,7 +5772,7 @@ end: static int ust_app_channel_synchronize_event(struct ust_app_channel *ua_chan, - struct ltt_ust_event *uevent, struct ust_app_session *ua_sess, + struct ltt_ust_event *uevent, struct ust_app *app) { int ret = 0; @@ -5778,15 +5781,15 @@ int ust_app_channel_synchronize_event(struct ust_app_channel *ua_chan, ua_event = find_ust_app_event(ua_chan->events, uevent->attr.name, uevent->filter, uevent->attr.loglevel, uevent->exclusion); if (!ua_event) { - ret = create_ust_app_event(ua_sess, ua_chan, uevent, app); + ret = create_ust_app_event(ua_chan, uevent, app); if (ret < 0) { goto end; } } else { if (ua_event->enabled != uevent->enabled) { ret = uevent->enabled ? - enable_ust_app_event(ua_sess, ua_event, app) : - disable_ust_app_event(ua_sess, ua_event, app); + enable_ust_app_event(ua_event, app) : + disable_ust_app_event(ua_event, app); } } @@ -5806,6 +5809,8 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app) struct ust_app_event_notifier_rule *event_notifier_rule; unsigned int count, i; + ASSERT_RCU_READ_LOCKED(); + if (!ust_app_supports_notifiers(app)) { goto end; } @@ -5957,6 +5962,7 @@ void ust_app_synchronize_all_channels(struct ltt_ust_session *usess, LTTNG_ASSERT(usess); LTTNG_ASSERT(ua_sess); LTTNG_ASSERT(app); + ASSERT_RCU_READ_LOCKED(); cds_lfht_for_each_entry(usess->domain_global.channels->ht, &uchan_iter, uchan, node.node) { @@ -5986,7 +5992,7 @@ void ust_app_synchronize_all_channels(struct ltt_ust_session *usess, cds_lfht_for_each_entry(uchan->events->ht, &uevent_iter, uevent, node.node) { ret = ust_app_channel_synchronize_event(ua_chan, - uevent, ua_sess, app); + uevent, app); if (ret) { goto end; } @@ -6086,6 +6092,7 @@ void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app) { LTTNG_ASSERT(usess); LTTNG_ASSERT(usess->active); + ASSERT_RCU_READ_LOCKED(); DBG2("UST app global update for app sock %d for session id %" PRIu64, app->sock, usess->id); @@ -6120,6 +6127,8 @@ void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app) */ void ust_app_global_update_event_notifier_rules(struct ust_app *app) { + ASSERT_RCU_READ_LOCKED(); + DBG2("UST application global event notifier rules update: app = '%s', pid = %d", app->name, app->pid); @@ -6282,6 +6291,7 @@ static struct ust_app_session *find_session_by_objd(struct ust_app *app, struct ust_app_session *ua_sess = NULL; LTTNG_ASSERT(app); + ASSERT_RCU_READ_LOCKED(); lttng_ht_lookup(app->ust_sessions_objd, (void *)((unsigned long) objd), &iter); node = lttng_ht_iter_get_node_ulong(&iter); @@ -6309,6 +6319,7 @@ static struct ust_app_channel *find_channel_by_objd(struct ust_app *app, struct ust_app_channel *ua_chan = NULL; LTTNG_ASSERT(app); + ASSERT_RCU_READ_LOCKED(); lttng_ht_lookup(app->ust_objd, (void *)((unsigned long) objd), &iter); node = lttng_ht_iter_get_node_ulong(&iter); @@ -6323,6 +6334,106 @@ error: return ua_chan; } +/* + * Fixup legacy context fields for comparison: + * - legacy array becomes array_nestable, + * - legacy struct becomes struct_nestable, + * - legacy variant becomes variant_nestable, + * legacy sequences are not emitted in LTTng-UST contexts. + */ +static int ust_app_fixup_legacy_context_fields(size_t *_nr_fields, + struct lttng_ust_ctl_field **_fields) +{ + struct lttng_ust_ctl_field *fields = *_fields, *new_fields = NULL; + size_t nr_fields = *_nr_fields, new_nr_fields = 0, i, j; + bool found = false; + int ret = 0; + + for (i = 0; i < nr_fields; i++) { + const struct lttng_ust_ctl_field *field = &fields[i]; + + switch (field->type.atype) { + case lttng_ust_ctl_atype_sequence: + ERR("Unexpected legacy sequence context."); + ret = -EINVAL; + goto end; + case lttng_ust_ctl_atype_array: + switch (field->type.u.legacy.array.elem_type.atype) { + case lttng_ust_ctl_atype_integer: + break; + default: + ERR("Unexpected legacy array element type in context."); + ret = -EINVAL; + goto end; + } + found = true; + /* One field for array_nested, one field for elem type. */ + new_nr_fields += 2; + break; + + case lttng_ust_ctl_atype_struct: /* Fallthrough */ + case lttng_ust_ctl_atype_variant: + found = true; + new_nr_fields++; + break; + default: + new_nr_fields++; + break; + } + } + if (!found) { + goto end; + } + + new_fields = calloc(new_nr_fields); + if (!new_fields) { + ret = -ENOMEM; + goto end; + } + + for (i = 0, j = 0; i < nr_fields; i++, j++) { + const struct lttng_ust_ctl_field *field = &fields[i]; + struct lttng_ust_ctl_field *new_field = &new_fields[j]; + + switch (field->type.atype) { + case lttng_ust_ctl_atype_array: + /* One field for array_nested, one field for elem type. */ + strncpy(new_field->name, field->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + new_field->type.atype = lttng_ust_ctl_atype_array_nestable; + new_field->type.u.array_nestable.length = field->type.u.legacy.array.length; + new_field->type.u.array_nestable.alignment = 0; + new_field = &new_fields[++j]; /* elem type */ + new_field->type.atype = field->type.u.legacy.array.elem_type.atype; + assert(new_field->type.atype == lttng_ust_ctl_atype_integer); + new_field->type.u.integer = field->type.u.legacy.array.elem_type.u.basic.integer; + break; + case lttng_ust_ctl_atype_struct: + strncpy(new_field->name, field->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + new_field->type.atype = lttng_ust_ctl_atype_struct_nestable; + new_field->type.u.struct_nestable.nr_fields = field->type.u.legacy._struct.nr_fields; + new_field->type.u.struct_nestable.alignment = 0; + break; + case lttng_ust_ctl_atype_variant: + strncpy(new_field->name, field->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1); + new_field->type.atype = lttng_ust_ctl_atype_variant_nestable; + new_field->type.u.variant_nestable.nr_choices = field->type.u.legacy.variant.nr_choices; + strncpy(new_field->type.u.variant_nestable.tag_name, + field->type.u.legacy.variant.tag_name, + LTTNG_UST_ABI_SYM_NAME_LEN - 1); + new_field->type.u.variant_nestable.alignment = 0; + break; + default: + *new_field = *field; + break; + } + } + free(fields); + *_fields = new_fields; + *_nr_fields = new_nr_fields; +end: + return ret; +} + /* * Reply to a register channel notification from an application on the notify * socket. The channel metadata is also created. @@ -6337,11 +6448,11 @@ static int reply_ust_register_channel(int sock, int cobjd, int ret, ret_code = 0; uint32_t chan_id; uint64_t chan_reg_key; - enum lttng_ust_ctl_channel_header type; + enum lttng_ust_ctl_channel_header type = LTTNG_UST_CTL_CHANNEL_HEADER_UNKNOWN; struct ust_app *app; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; struct ust_registry_channel *ust_reg_chan; rcu_read_lock(); @@ -6381,7 +6492,7 @@ static int reply_ust_register_channel(int sock, int cobjd, chan_reg_key = ua_chan->key; } - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); ust_reg_chan = ust_registry_channel_find(registry, chan_reg_key); LTTNG_ASSERT(ust_reg_chan); @@ -6389,6 +6500,13 @@ static int reply_ust_register_channel(int sock, int cobjd, /* Channel id is set during the object creation. */ chan_id = ust_reg_chan->chan_id; + ret = ust_app_fixup_legacy_context_fields(&nr_fields, &fields); + if (ret < 0) { + ERR("Registering application channel due to legacy context fields fixup error: pid = %d, sock = %d", + app->pid, app->sock); + ret_code = -EINVAL; + goto reply; + } if (!ust_reg_chan->register_done) { /* * TODO: eventually use the registry event count for @@ -6450,7 +6568,7 @@ reply: ust_reg_chan->register_done = 1; error: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); error_rcu_unlock: rcu_read_unlock(); free(fields); @@ -6476,7 +6594,7 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, struct ust_app *app; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; rcu_read_lock(); @@ -6513,7 +6631,7 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, chan_reg_key = ua_chan->key; } - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); /* * From this point on, this call acquires the ownership of the sig, fields @@ -6556,7 +6674,7 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, char *name, name, event_id); error: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); error_rcu_unlock: rcu_read_unlock(); free(sig); @@ -6579,7 +6697,7 @@ static int add_enum_ust_registry(int sock, int sobjd, char *name, int ret = 0, ret_code; struct ust_app *app; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; uint64_t enum_id = -1ULL; rcu_read_lock(); @@ -6611,7 +6729,7 @@ static int add_enum_ust_registry(int sock, int sobjd, char *name, goto error_rcu_unlock; } - pthread_mutex_lock(®istry->lock); + pthread_mutex_lock(®istry->_lock); /* * From this point on, the callee acquires the ownership of @@ -6649,7 +6767,7 @@ static int add_enum_ust_registry(int sock, int sobjd, char *name, DBG3("UST registry enum %s added successfully or already found", name); error: - pthread_mutex_unlock(®istry->lock); + pthread_mutex_unlock(®istry->_lock); error_rcu_unlock: rcu_read_unlock(); return ret; @@ -6823,7 +6941,7 @@ void ust_app_notify_sock_unregister(int sock) rcu_read_lock(); - obj = (ust_app_notify_sock_obj *) zmalloc(sizeof(*obj)); + obj = zmalloc(); if (!obj) { /* * An ENOMEM is kind of uncool. If this strikes we continue the @@ -6900,7 +7018,7 @@ void ust_app_destroy(struct ust_app *app) */ enum lttng_error_code ust_app_snapshot_record( const struct ltt_ust_session *usess, - const struct consumer_output *output, int wait, + const struct consumer_output *output, uint64_t nb_packets_per_stream) { int ret = 0; @@ -6925,7 +7043,7 @@ enum lttng_error_code ust_app_snapshot_record( char pathname[PATH_MAX]; size_t consumer_path_offset = 0; - if (!reg->registry->reg.ust->metadata_key) { + if (!reg->registry->reg.ust->_metadata_key) { /* Skip since no metadata is present */ continue; } @@ -6960,17 +7078,15 @@ enum lttng_error_code ust_app_snapshot_record( buf_reg_chan, node.node) { status = consumer_snapshot_channel(socket, buf_reg_chan->consumer_key, - output, 0, usess->uid, - usess->gid, &trace_path[consumer_path_offset], wait, + output, 0, &trace_path[consumer_path_offset], nb_packets_per_stream); if (status != LTTNG_OK) { goto error; } } status = consumer_snapshot_channel(socket, - reg->registry->reg.ust->metadata_key, output, 1, - usess->uid, usess->gid, &trace_path[consumer_path_offset], - wait, 0); + reg->registry->reg.ust->_metadata_key, output, 1, + &trace_path[consumer_path_offset], 0); if (status != LTTNG_OK) { goto error; } @@ -6984,7 +7100,7 @@ enum lttng_error_code ust_app_snapshot_record( struct lttng_ht_iter chan_iter; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; char pathname[PATH_MAX]; size_t consumer_path_offset = 0; @@ -7023,9 +7139,7 @@ enum lttng_error_code ust_app_snapshot_record( ua_chan, node.node) { status = consumer_snapshot_channel(socket, ua_chan->key, output, 0, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - &trace_path[consumer_path_offset], wait, + &trace_path[consumer_path_offset], nb_packets_per_stream); switch (status) { case LTTNG_OK: @@ -7043,10 +7157,8 @@ enum lttng_error_code ust_app_snapshot_record( continue; } status = consumer_snapshot_channel(socket, - registry->metadata_key, output, 1, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), - &trace_path[consumer_path_offset], wait, 0); + registry->_metadata_key, output, 1, + &trace_path[consumer_path_offset], 0); switch (status) { case LTTNG_OK: break; @@ -7339,7 +7451,6 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) buf_reg_chan, node.node) { ret = consumer_rotate_channel(socket, buf_reg_chan->consumer_key, - usess->uid, usess->gid, usess->consumer, /* is_metadata_channel */ false); if (ret < 0) { @@ -7356,7 +7467,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) * operations (i.e add context) and lead to data * channels created with no metadata channel. */ - if (!reg->registry->reg.ust->metadata_key) { + if (!reg->registry->reg.ust->_metadata_key) { /* Skip since no metadata is present. */ continue; } @@ -7364,8 +7475,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) (void) push_metadata(reg->registry->reg.ust, usess->consumer); ret = consumer_rotate_channel(socket, - reg->registry->reg.ust->metadata_key, - usess->uid, usess->gid, + reg->registry->reg.ust->_metadata_key, usess->consumer, /* is_metadata_channel */ true); if (ret < 0) { @@ -7382,7 +7492,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) struct lttng_ht_iter chan_iter; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; ua_sess = lookup_session_by_app(usess, app); if (!ua_sess) { @@ -7409,8 +7519,6 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) ua_chan, node.node) { ret = consumer_rotate_channel(socket, ua_chan->key, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), ua_sess->consumer, /* is_metadata_channel */ false); if (ret < 0) { @@ -7425,9 +7533,7 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session) /* Rotate the metadata channel. */ (void) push_metadata(registry, usess->consumer); ret = consumer_rotate_channel(socket, - registry->metadata_key, - lttng_credentials_get_uid(&ua_sess->effective_credentials), - lttng_credentials_get_gid(&ua_sess->effective_credentials), + registry->_metadata_key, ua_sess->consumer, /* is_metadata_channel */ true); if (ret < 0) { @@ -7512,7 +7618,7 @@ enum lttng_error_code ust_app_create_channel_subdirectories( cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) { struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; ua_sess = lookup_session_by_app(usess, app); if (!ua_sess) { @@ -7617,7 +7723,7 @@ enum lttng_error_code ust_app_clear_session(struct ltt_session *session) * perform a rotation operation on it behind the scene. */ ret = consumer_clear_channel(socket, - reg->registry->reg.ust->metadata_key); + reg->registry->reg.ust->_metadata_key); if (ret < 0) { goto error; } @@ -7631,7 +7737,7 @@ enum lttng_error_code ust_app_clear_session(struct ltt_session *session) struct lttng_ht_iter chan_iter; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; ua_sess = lookup_session_by_app(usess, app); if (!ua_sess) { @@ -7673,7 +7779,7 @@ enum lttng_error_code ust_app_clear_session(struct ltt_session *session) * Metadata channel is not cleared per se but we still need to * perform rotation operation on it behind the scene. */ - ret = consumer_clear_channel(socket, registry->metadata_key); + ret = consumer_clear_channel(socket, registry->_metadata_key); if (ret < 0) { /* Per-PID buffer and application going away. */ if (ret == -LTTNG_ERR_CHAN_NOT_FOUND) { @@ -7775,7 +7881,7 @@ enum lttng_error_code ust_app_open_packets(struct ltt_session *session) struct lttng_ht_iter chan_iter; struct ust_app_channel *ua_chan; struct ust_app_session *ua_sess; - struct ust_registry_session *registry; + ust_registry_session *registry; ua_sess = lookup_session_by_app(usess, app); if (!ua_sess) {