/*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
* Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
*
* SPDX-License-Identifier: GPL-2.0-only
#include <unistd.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/trace-chunk.h>
-#include <common/utils.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/utils.hpp>
-#include "buffer-registry.h"
-#include "trace-ust.h"
-#include "utils.h"
-#include "ust-app.h"
-#include "agent.h"
+#include "buffer-registry.hpp"
+#include "trace-ust.hpp"
+#include "utils.hpp"
+#include "ust-app.hpp"
+#include "agent.hpp"
+
+namespace lsu = lttng::sessiond::ust;
/*
* Match function for the events hash table lookup.
struct lttng_ht_node_str *node;
struct lttng_ht_iter iter;
+ ASSERT_RCU_READ_LOCKED();
/*
* If we receive an empty string for channel name, it means the
* default channel name is requested.
DBG2("Trace UST channel %s found by name", name);
- return caa_container_of(node, struct ltt_ust_channel, node);
+ return lttng::utils::container_of(node, <t_ust_channel::node);
error:
DBG2("Trace UST channel %s not found by name", name);
LTTNG_ASSERT(name);
LTTNG_ASSERT(ht);
+ ASSERT_RCU_READ_LOCKED();
key.name = name;
key.filter = filter;
DBG2("Trace UST event %s found", key.name);
- return caa_container_of(node, struct ltt_ust_event, node);
+ return lttng::utils::container_of(node, <t_ust_event::node);
error:
DBG2("Trace UST event %s NOT found", key.name);
if (!node) {
goto end;
}
- agt = caa_container_of(node, struct agent, node);
+ agt = lttng::utils::container_of(node, &agent::node);
end:
return agt;
struct ltt_ust_session *lus;
/* Allocate a new ltt ust session */
- lus = (ltt_ust_session *) zmalloc(sizeof(struct ltt_ust_session));
+ lus = zmalloc<ltt_ust_session>();
if (lus == NULL) {
PERROR("create ust session zmalloc");
goto error_alloc;
process_attr_tracker_destroy(lus->tracker_vpid);
process_attr_tracker_destroy(lus->tracker_vuid);
process_attr_tracker_destroy(lus->tracker_vgid);
- ht_cleanup_push(lus->domain_global.channels);
- ht_cleanup_push(lus->agents);
+ lttng_ht_destroy(lus->domain_global.channels);
+ lttng_ht_destroy(lus->agents);
free(lus);
error_alloc:
return NULL;
LTTNG_ASSERT(chan);
- luc = (ltt_ust_channel *) zmalloc(sizeof(struct ltt_ust_channel));
+ luc = zmalloc<ltt_ust_channel>();
if (luc == NULL) {
PERROR("ltt_ust_channel zmalloc");
goto error;
goto error;
}
- local_ust_event = (ltt_ust_event *) zmalloc(sizeof(struct ltt_ust_event));
+ local_ust_event = zmalloc<ltt_ust_event>();
if (local_ust_event == NULL) {
PERROR("ust event zmalloc");
ret = LTTNG_ERR_NOMEM;
goto end;
}
- uctx = (ltt_ust_context *) zmalloc(sizeof(struct ltt_ust_context));
+ uctx = zmalloc<ltt_ust_context>();
if (!uctx) {
PERROR("zmalloc ltt_ust_context");
goto end;
destroy_id_tracker_node(tracker_node);
}
rcu_read_unlock();
- ht_cleanup_push(id_tracker->ht);
+ lttng_ht_destroy(id_tracker->ht);
id_tracker->ht = NULL;
}
lttng_ht_lookup(id_tracker->ht, (void *) _id, iter);
node = lttng_ht_iter_get_node_ulong(iter);
if (node) {
- return caa_container_of(node, struct ust_id_tracker_node, node);
+ return lttng::utils::container_of(node, &ust_id_tracker_node::node);
} else {
return NULL;
}
retval = LTTNG_ERR_PROCESS_ATTR_EXISTS;
goto end;
}
- tracker_node = (ust_id_tracker_node *) zmalloc(sizeof(*tracker_node));
+ tracker_node = zmalloc<ust_id_tracker_node>();
if (!tracker_node) {
retval = LTTNG_ERR_NOMEM;
goto end;
static void destroy_context_rcu(struct rcu_head *head)
{
struct lttng_ht_node_ulong *node =
- caa_container_of(head, struct lttng_ht_node_ulong, head);
+ lttng::utils::container_of(head, <tng_ht_node_ulong::head);
struct ltt_ust_context *ctx =
- caa_container_of(node, struct ltt_ust_context, node);
+ lttng::utils::container_of(node, <t_ust_context::node);
trace_ust_destroy_context(ctx);
}
rcu_read_lock();
cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
/* Remove from ordered list. */
- ctx = caa_container_of(node, struct ltt_ust_context, node);
+ ctx = lttng::utils::container_of(node, <t_ust_context::node);
cds_list_del(&ctx->list);
/* Remove from channel's hash table. */
ret = lttng_ht_del(ht, &iter);
}
rcu_read_unlock();
- ht_cleanup_push(ht);
+ lttng_ht_destroy(ht);
}
/*
static void destroy_event_rcu(struct rcu_head *head)
{
struct lttng_ht_node_str *node =
- caa_container_of(head, struct lttng_ht_node_str, head);
+ lttng::utils::container_of(head, <tng_ht_node_str::head);
struct ltt_ust_event *event =
- caa_container_of(node, struct ltt_ust_event, node);
+ lttng::utils::container_of(node, <t_ust_event::node);
trace_ust_destroy_event(event);
}
}
rcu_read_unlock();
- ht_cleanup_push(events);
+ lttng_ht_destroy(events);
}
/*
static void destroy_channel_rcu(struct rcu_head *head)
{
struct lttng_ht_node_str *node =
- caa_container_of(head, struct lttng_ht_node_str, head);
+ lttng::utils::container_of(head, <tng_ht_node_str::head);
struct ltt_ust_channel *channel =
- caa_container_of(node, struct ltt_ust_channel, node);
+ lttng::utils::container_of(node, <t_ust_channel::node);
_trace_ust_destroy_channel(channel);
}
LTTNG_ASSERT(!ret);
}
+int trace_ust_regenerate_metadata(struct ltt_ust_session *usess)
+{
+ int ret = 0;
+ struct buffer_reg_uid *uid_reg = NULL;
+ struct buffer_reg_session *session_reg = NULL;
+
+ rcu_read_lock();
+ cds_list_for_each_entry(uid_reg, &usess->buffer_reg_uid_list, lnode) {
+ lsu::registry_session *registry;
+
+ session_reg = uid_reg->registry;
+ registry = session_reg->reg.ust;
+
+ try {
+ registry->regenerate_metadata();
+ } catch (const std::exception& ex) {
+ ERR("Failed to regenerate user space session metadata: %s", ex.what());
+ ret = -1;
+ goto end;
+ }
+ }
+
+end:
+ rcu_read_unlock();
+ return ret;
+}
+
/*
* Iterate over a hash table containing channels and cleanup safely.
*/
rcu_read_lock();
cds_lfht_for_each_entry(channels->ht, &iter.iter, node, node) {
struct ltt_ust_channel *chan =
- caa_container_of(node, struct ltt_ust_channel, node);
+ lttng::utils::container_of(node, <t_ust_channel::node);
trace_ust_delete_channel(channels, chan);
trace_ust_destroy_channel(chan);
}
rcu_read_unlock();
- ht_cleanup_push(channels);
+ lttng_ht_destroy(channels);
}
/*
/*
* Cleanup ust session structure, keeping data required by
* destroy notifier.
- *
- * Should *NOT* be called with RCU read-side lock held.
*/
void trace_ust_destroy_session(struct ltt_ust_session *session)
{
}
rcu_read_unlock();
- ht_cleanup_push(session->agents);
+ lttng_ht_destroy(session->agents);
/* Cleanup UID buffer registry object(s). */
cds_list_for_each_entry_safe(reg, sreg, &session->buffer_reg_uid_list,