#include <common/common.hpp>
#include <common/defaults.hpp>
#include <common/trace-chunk.hpp>
+#include <common/urcu.hpp>
#include <common/utils.hpp>
#include <inttypes.h>
lttng_ht_lookup(ht, (void *) name, &iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
error:
DBG2("Trace UST channel %s not found by name", name);
- return NULL;
+ return nullptr;
}
/*
&key,
&iter.iter);
node = lttng_ht_iter_get_node_str(&iter);
- if (node == NULL) {
+ if (node == nullptr) {
goto error;
}
error:
DBG2("Trace UST event %s NOT found", key.name);
- return NULL;
+ return nullptr;
}
/*
struct agent *trace_ust_find_agent(struct ltt_ust_session *session,
enum lttng_domain_type domain_type)
{
- struct agent *agt = NULL;
+ struct agent *agt = nullptr;
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
uint64_t key;
/* Allocate a new ltt ust session */
lus = zmalloc<ltt_ust_session>();
- if (lus == NULL) {
+ if (lus == nullptr) {
PERROR("create ust session zmalloc");
goto error_alloc;
}
goto error;
}
lus->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
- if (lus->consumer == NULL) {
+ if (lus->consumer == nullptr) {
goto error;
}
lttng_ht_destroy(lus->agents);
free(lus);
error_alloc:
- return NULL;
+ return nullptr;
}
/*
LTTNG_ASSERT(chan);
luc = zmalloc<ltt_ust_channel>();
- if (luc == NULL) {
+ if (luc == nullptr) {
PERROR("ltt_ust_channel zmalloc");
goto error;
}
}
local_ust_event = zmalloc<ltt_ust_event>();
- if (local_ust_event == NULL) {
+ if (local_ust_event == nullptr) {
PERROR("ust event zmalloc");
ret = LTTNG_ERR_NOMEM;
goto error;
}
if (strncmp(uctx->ctx.u.perf_counter.name,
ctx->u.perf_counter.name,
- LTTNG_UST_ABI_SYM_NAME_LEN)) {
+ LTTNG_UST_ABI_SYM_NAME_LEN) != 0) {
return 0;
}
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
LTTNG_ASSERT(uctx->ctx.u.app_ctx.provider_name);
LTTNG_ASSERT(uctx->ctx.u.app_ctx.ctx_name);
- if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) ||
- strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name)) {
+ if (strcmp(uctx->ctx.u.app_ctx.provider_name, ctx->u.app_ctx.provider_name) != 0 ||
+ strcmp(uctx->ctx.u.app_ctx.ctx_name, ctx->u.app_ctx.ctx_name) != 0) {
return 0;
}
default:
*/
struct ltt_ust_context *trace_ust_create_context(const struct lttng_event_context *ctx)
{
- struct ltt_ust_context *uctx = NULL;
+ struct ltt_ust_context *uctx = nullptr;
int utype;
LTTNG_ASSERT(ctx);
break;
case LTTNG_UST_ABI_CONTEXT_APP_CONTEXT:
{
- char *provider_name = NULL, *ctx_name = NULL;
+ char *provider_name = nullptr, *ctx_name = nullptr;
provider_name = strdup(ctx->u.app_ctx.provider_name);
if (!provider_name) {
return uctx;
error:
trace_ust_destroy_context(uctx);
- return NULL;
+ return nullptr;
}
static void destroy_id_tracker_node_rcu(struct rcu_head *head)
if (!id_tracker->ht) {
return;
}
- rcu_read_lock();
- cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) {
- int ret = lttng_ht_del(id_tracker->ht, &iter);
- LTTNG_ASSERT(!ret);
- destroy_id_tracker_node(tracker_node);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (id_tracker->ht->ht, &iter.iter, tracker_node, node.node) {
+ int ret = lttng_ht_del(id_tracker->ht, &iter);
+
+ LTTNG_ASSERT(!ret);
+ destroy_id_tracker_node(tracker_node);
+ }
}
- rcu_read_unlock();
+
lttng_ht_destroy(id_tracker->ht);
- id_tracker->ht = NULL;
+ id_tracker->ht = nullptr;
}
static struct ust_id_tracker_node *
if (node) {
return lttng::utils::container_of(node, &ust_id_tracker_node::node);
} else {
- return NULL;
+ return nullptr;
}
}
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
return &session->vgid_tracker;
default:
- return NULL;
+ return nullptr;
}
}
case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
return session->tracker_vgid;
default:
- return NULL;
+ return nullptr;
}
}
LTTNG_ASSERT(ht);
- rcu_read_lock();
- cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) {
- /* Remove from ordered list. */
- 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);
- if (!ret) {
- call_rcu(&node->head, destroy_context_rcu);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (ht->ht, &iter.iter, node, node) {
+ /* Remove from ordered list. */
+ 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);
+ if (!ret) {
+ call_rcu(&node->head, destroy_context_rcu);
+ }
}
}
- rcu_read_unlock();
lttng_ht_destroy(ht);
}
LTTNG_ASSERT(events);
- rcu_read_lock();
- cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) {
- ret = lttng_ht_del(events, &iter);
- LTTNG_ASSERT(!ret);
- call_rcu(&node->head, destroy_event_rcu);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (events->ht, &iter.iter, node, node) {
+ ret = lttng_ht_del(events, &iter);
+ LTTNG_ASSERT(!ret);
+ call_rcu(&node->head, destroy_event_rcu);
+ }
}
- rcu_read_unlock();
lttng_ht_destroy(events);
}
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;
+ struct buffer_reg_uid *uid_reg = nullptr;
+ struct buffer_reg_session *session_reg = nullptr;
- rcu_read_lock();
+ lttng::urcu::read_lock_guard read_lock;
cds_list_for_each_entry (uid_reg, &usess->buffer_reg_uid_list, lnode) {
lsu::registry_session *registry;
}
end:
- rcu_read_unlock();
return ret;
}
LTTNG_ASSERT(channels);
- rcu_read_lock();
- cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) {
- struct ltt_ust_channel *chan =
- lttng::utils::container_of(node, <t_ust_channel::node);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (channels->ht, &iter.iter, node, node) {
+ struct ltt_ust_channel *chan =
+ lttng::utils::container_of(node, <t_ust_channel::node);
- trace_ust_delete_channel(channels, chan);
- trace_ust_destroy_channel(chan);
+ trace_ust_delete_channel(channels, chan);
+ trace_ust_destroy_channel(chan);
+ }
}
- rcu_read_unlock();
lttng_ht_destroy(channels);
}
/* Cleaning up UST domain */
destroy_domain_global(&session->domain_global);
- rcu_read_lock();
- cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) {
- int ret = lttng_ht_del(session->agents, &iter);
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (session->agents->ht, &iter.iter, agt, node.node) {
+ int ret = lttng_ht_del(session->agents, &iter);
- LTTNG_ASSERT(!ret);
- agent_destroy(agt);
+ LTTNG_ASSERT(!ret);
+ agent_destroy(agt);
+ }
}
- rcu_read_unlock();
lttng_ht_destroy(session->agents);