#include <common/error.hpp>
#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/urcu.hpp>
#include <stdio.h>
#include <unistd.h>
struct ltt_kernel_context *kctx)
{
int ret;
- struct ltt_kernel_channel *kchan;
LTTNG_ASSERT(ksession);
LTTNG_ASSERT(kctx);
DBG("Adding kernel context to all channels");
/* Go over all channels */
- cds_list_for_each_entry (kchan, &ksession->channel_list.head, list) {
+ for (auto kchan :
+ lttng::urcu::list_iteration_adapter<ltt_kernel_channel, <t_kernel_channel::list>(
+ ksession->channel_list.head)) {
struct ltt_kernel_context *kctx_copy;
kctx_copy = trace_kernel_copy_context(kctx);
const struct lttng_event_context *ctx)
{
int ret;
- struct ltt_ust_context *uctx = nullptr;
+ struct ltt_ust_context *new_uctx = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(uchan);
LTTNG_ASSERT(ctx);
/* Check if context is duplicate */
- cds_list_for_each_entry (uctx, &uchan->ctx_list, list) {
- if (trace_ust_match_context(uctx, ctx)) {
+ for (auto uctx_it :
+ lttng::urcu::list_iteration_adapter<ltt_ust_context, <t_ust_context::list>(
+ uchan->ctx_list)) {
+ if (trace_ust_match_context(uctx_it, ctx)) {
ret = LTTNG_ERR_UST_CONTEXT_EXIST;
goto duplicate;
}
}
- uctx = nullptr;
switch (domain) {
case LTTNG_DOMAIN_JUL:
case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_LOG4J2:
{
struct agent *agt;
}
/* Create ltt UST context */
- uctx = trace_ust_create_context(ctx);
- if (uctx == nullptr) {
+ new_uctx = trace_ust_create_context(ctx);
+ if (new_uctx == nullptr) {
ret = LTTNG_ERR_UST_CONTEXT_INVAL;
goto error;
}
/* Add ltt UST context node to ltt UST channel */
- lttng_ht_add_ulong(uchan->ctx, &uctx->node);
- cds_list_add_tail(&uctx->list, &uchan->ctx_list);
+ lttng_ht_add_ulong(uchan->ctx, &new_uctx->node);
+ cds_list_add_tail(&new_uctx->list, &uchan->ctx_list);
if (!usess->active) {
goto end;
}
- ret = ust_app_add_ctx_channel_glb(usess, uchan, uctx);
+ ret = ust_app_add_ctx_channel_glb(usess, uchan, new_uctx);
if (ret < 0) {
goto error;
}
end:
- DBG("Context UST %d added to channel %s", uctx->ctx.ctx, uchan->name);
+ DBG("Context UST %d added to channel %s", new_uctx->ctx.ctx, uchan->name);
return 0;
error:
- free(uctx);
+ free(new_uctx);
duplicate:
return ret;
}
const char *channel_name)
{
int ret = LTTNG_OK;
- struct lttng_ht_iter iter;
struct lttng_ht *chan_ht;
- struct ltt_ust_channel *uchan = nullptr;
+ ltt_ust_channel *uchan = nullptr;
LTTNG_ASSERT(usess);
LTTNG_ASSERT(ctx);
LTTNG_ASSERT(channel_name);
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
chan_ht = usess->domain_global.channels;
/* Add ctx to channel */
ret = add_uctx_to_channel(usess, domain, uchan, ctx);
} else {
- rcu_read_lock();
/* Add ctx all events, all channels */
- cds_lfht_for_each_entry (chan_ht->ht, &iter.iter, uchan, node.node) {
- ret = add_uctx_to_channel(usess, domain, uchan, ctx);
+ for (auto *iterated_uchan :
+ lttng::urcu::lfht_iteration_adapter<ltt_ust_channel,
+ decltype(ltt_ust_channel::node),
+ <t_ust_channel::node>(*chan_ht->ht)) {
+ ret = add_uctx_to_channel(usess, domain, iterated_uchan, ctx);
if (ret) {
- ERR("Failed to add context to channel %s", uchan->name);
+ ERR("Failed to add context to channel %s", iterated_uchan->name);
continue;
}
}
- rcu_read_unlock();
}
switch (ret) {
}
error:
- rcu_read_unlock();
return ret;
}