#include <urcu/compiler.h>
#include <signal.h>
-#include <common/bytecode/bytecode.h>
-#include <common/compat/errno.h>
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/bytecode/bytecode.hpp>
+#include <common/compat/errno.hpp>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
#include <lttng/event-rule/event-rule.h>
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
#include <lttng/event-rule/user-tracepoint.h>
#include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches-internal.hpp>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/trigger/trigger-internal.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-
-#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 <lttng/trigger/trigger-internal.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+
+#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;
int ret;
LTTNG_ASSERT(ua_ctx);
+ ASSERT_RCU_READ_LOCKED();
if (ua_ctx->obj) {
pthread_mutex_lock(&app->sock_lock);
int ret;
LTTNG_ASSERT(ua_event);
+ ASSERT_RCU_READ_LOCKED();
free(ua_event->filter);
if (ua_event->exclusion != NULL)
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);
}
struct ust_registry_session *registry;
LTTNG_ASSERT(ua_chan);
+ ASSERT_RCU_READ_LOCKED();
DBG3("UST app deleting channel %s", ua_chan->name);
LTTNG_ASSERT(registry);
LTTNG_ASSERT(socket);
+ ASSERT_RCU_READ_LOCKED();
metadata_key = registry->metadata_key;
}
/* Allocate only what we have to send. */
- metadata_str = (char *) zmalloc(len);
+ metadata_str = calloc<char>(len);
if (!metadata_str) {
PERROR("zmalloc ust app metadata string");
ret_val = -ENOMEM;
LTTNG_ASSERT(registry);
LTTNG_ASSERT(consumer);
+ ASSERT_RCU_READ_LOCKED();
pthread_mutex_lock(®istry->lock);
if (registry->metadata_closed) {
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);
}
struct ust_registry_session *registry;
LTTNG_ASSERT(ua_sess);
+ ASSERT_RCU_READ_LOCKED();
pthread_mutex_lock(&ua_sess->lock);
/*
* 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)
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
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<ust_app_session>();
if (ua_sess == NULL) {
PERROR("malloc");
goto error_free;
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<ust_app_channel>();
if (ua_chan == NULL) {
PERROR("malloc");
goto error;
{
struct ust_app_stream *stream = NULL;
- stream = (ust_app_stream *) zmalloc(sizeof(*stream));
+ stream = zmalloc<ust_app_stream>();
if (stream == NULL) {
PERROR("zmalloc ust app stream");
goto error;
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<ust_app_event>();
if (ua_event == NULL) {
PERROR("Failed to allocate ust_app_event structure");
goto error;
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<ust_app_event_notifier_rule>();
if (ua_event_notifier_rule == NULL) {
PERROR("Failed to allocate ust_app_event_notifier_rule structure");
goto error;
{
struct ust_app_ctx *ua_ctx;
- ua_ctx = (ust_app_ctx *) zmalloc(sizeof(struct ust_app_ctx));
+ ua_ctx = zmalloc<ust_app_ctx>();
if (ua_ctx == NULL) {
goto error;
}
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<lttng_ust_abi_filter_bytecode>(sizeof(*filter) + orig_f->len);
if (!filter) {
PERROR("Failed to allocate lttng_ust_filter_bytecode: bytecode len = %" PRIu32 " bytes", orig_f->len);
goto error;
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<lttng_ust_abi_capture_bytecode>(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;
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) {
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);
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);
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<lttng_ust_abi_event_exclusion>(exclusion_alloc_size);
if (!ust_exclusion) {
PERROR("malloc");
goto end;
* 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;
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);
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<lttng_event_exclusion>(exclusion_alloc_size);
if (ua_event->exclusion == NULL) {
PERROR("malloc");
} else {
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),
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);
* 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;
/*
* 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;
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) {
*/
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, struct ust_registry_session *registry)
{
int ret;
unsigned int nb_fd = 0;
/* 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) {
* 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;
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);
* 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);
/* 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);
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) {
*/
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;
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);
* 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(). */
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
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;
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. */
goto error;
}
- lta = (ust_app *) zmalloc(sizeof(struct ust_app));
+ lta = zmalloc<ust_app>();
if (lta == NULL) {
PERROR("malloc");
goto error_free_pipe;
struct lttng_event *tmp_event;
nbmem = UST_APP_EVENT_LIST_SIZE;
- tmp_event = (lttng_event *) zmalloc(nbmem * sizeof(struct lttng_event));
+ tmp_event = calloc<lttng_event>(nbmem);
if (tmp_event == NULL) {
PERROR("zmalloc ust app events");
ret = -ENOMEM;
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<lttng_event_field>(nbmem);
if (tmp_event == NULL) {
PERROR("zmalloc ust app event fields");
ret = -ENOMEM;
/*
* 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)
{
/* 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);
}
}
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;
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;
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) {
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;
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);
}
}
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;
}
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) {
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;
}
{
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);
*/
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);
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);
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);
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<lttng_ust_ctl_field>(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.
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;
/* 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
rcu_read_lock();
- obj = (ust_app_notify_sock_obj *) zmalloc(sizeof(*obj));
+ obj = zmalloc<ust_app_notify_sock_obj>();
if (!obj) {
/*
* An ENOMEM is kind of uncool. If this strikes we continue the
*/
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;
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);
+ &trace_path[consumer_path_offset], 0);
if (status != LTTNG_OK) {
goto error;
}
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:
}
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);
+ &trace_path[consumer_path_offset], 0);
switch (status) {
case LTTNG_OK:
break;
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) {
ret = consumer_rotate_channel(socket,
reg->registry->reg.ust->metadata_key,
- usess->uid, usess->gid,
usess->consumer,
/* is_metadata_channel */ true);
if (ret < 0) {
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) {
(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),
ua_sess->consumer,
/* is_metadata_channel */ true);
if (ret < 0) {