#include <urcu/rculist.h>
#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/jul-logging.h>
#include <lttng/event-rule/log4j-logging.h>
#include <lttng/event-rule/python-logging.h>
#include <lttng/condition/condition.h>
#include <lttng/condition/event-rule-matches.h>
-#include <lttng/domain-internal.h>
-#include <lttng/log-level-rule-internal.h>
+#include <lttng/domain-internal.hpp>
+#include <lttng/log-level-rule-internal.hpp>
-#include <common/common.h>
-#include <common/sessiond-comm/agent.h>
+#include <common/common.hpp>
+#include <common/sessiond-comm/agent.hpp>
-#include <common/compat/endian.h>
+#include <common/compat/endian.hpp>
-#include "agent.h"
-#include "ust-app.h"
-#include "utils.h"
-#include "common/error.h"
+#include "agent.hpp"
+#include "ust-app.hpp"
+#include "utils.hpp"
+#include "common/error.hpp"
typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
const struct lttng_event_rule *rule, const char **pattern);
/*
* Agent application context representation.
*/
+namespace {
struct agent_app_ctx {
char *provider_name;
char *ctx_name;
/* For call_rcu teardown. */
struct rcu_head rcu_node;
};
+} /* namespace */
/*
* Human readable agent return code.
static void destroy_event_agent_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 agent_event *event =
- caa_container_of(node, struct agent_event, node);
+ lttng::utils::container_of(node, &agent_event::node);
agent_destroy_event(event);
}
static void destroy_app_agent_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 agent_app *app =
- caa_container_of(node, struct agent_app, node);
+ lttng::utils::container_of(node, &agent_app::node);
free(app);
}
goto error;
}
- reply = (lttcomm_agent_list_reply *) zmalloc(data_size);
+ reply = zmalloc<lttcomm_agent_list_reply>(data_size);
if (!reply) {
ret = LTTNG_ERR_NOMEM;
goto error;
}
nb_event = be32toh(reply->nb_event);
- tmp_events = (lttng_event *) zmalloc(sizeof(*tmp_events) * nb_event);
+ tmp_events = calloc<lttng_event>(nb_event);
if (!tmp_events) {
ret = LTTNG_ERR_NOMEM;
goto error;
goto error_io;
}
- bytes_to_send = (char *) zmalloc(data_size);
+ bytes_to_send = calloc<char>(data_size);
if (!bytes_to_send) {
ret = LTTNG_ERR_NOMEM;
goto error;
}
LTTNG_ASSERT(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
- agent_ctx = (agent_app_ctx *) zmalloc(sizeof(*ctx));
+ agent_ctx = zmalloc<agent_app_ctx>();
if (!agent_ctx) {
goto end;
}
DBG2("Agent listing events for domain %d", domain);
nbmem = UST_APP_EVENT_LIST_SIZE;
- tmp_events = (lttng_event *) zmalloc(nbmem * sizeof(*tmp_events));
+ tmp_events = calloc<lttng_event>(nbmem);
if (!tmp_events) {
PERROR("zmalloc agent list events");
ret = -ENOMEM;
LTTNG_ASSERT(sock);
- app = (agent_app *) zmalloc(sizeof(*app));
+ app = zmalloc<agent_app>();
if (!app) {
PERROR("Failed to allocate agent application instance");
goto error;
struct agent_app *app;
LTTNG_ASSERT(sock >= 0);
+ ASSERT_RCU_READ_LOCKED();
lttng_ht_lookup(the_agent_apps_ht_by_sock,
(void *) ((unsigned long) sock), &iter);
if (node == NULL) {
goto error;
}
- app = caa_container_of(node, struct agent_app, node);
+ app = lttng::utils::container_of(node, &agent_app::node);
DBG3("Agent app pid %d found by sock %d.", app->pid, sock);
return app;
struct lttng_ht_iter iter;
LTTNG_ASSERT(app);
+ ASSERT_RCU_READ_LOCKED();
DBG3("Agent deleting app pid: %d and sock: %d", app->pid, app->sock->fd);
int ret;
struct agent *agt;
- agt = (agent *) zmalloc(sizeof(struct agent));
+ agt = zmalloc<agent>();
if (!agt) {
goto error;
}
goto error;
}
- event = (agent_event *) zmalloc(sizeof(*event));
+ event = zmalloc<agent_event>();
if (!event) {
goto error;
}
LTTNG_ASSERT(agt);
LTTNG_ASSERT(agt->events);
LTTNG_ASSERT(iter);
+ ASSERT_RCU_READ_LOCKED();
ht = agt->events;
key.name = name;
LTTNG_ASSERT(agt);
LTTNG_ASSERT(agt->events);
+ ASSERT_RCU_READ_LOCKED();
condition = lttng_trigger_get_const_condition(trigger);
{
struct agent_ht_key key;
+ ASSERT_RCU_READ_LOCKED();
+
key.name = name;
cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name,
LTTNG_ASSERT(name);
LTTNG_ASSERT(agt);
LTTNG_ASSERT(agt->events);
+ ASSERT_RCU_READ_LOCKED();
ht = agt->events;
key.name = name;
}
DBG3("Agent event found %s.", name);
- return caa_container_of(node, struct agent_event, node);
+ return lttng::utils::container_of(node, &agent_event::node);
error:
DBG3("Agent event NOT found %s.", name);
void destroy_app_ctx_rcu(struct rcu_head *head)
{
struct agent_app_ctx *ctx =
- caa_container_of(head, struct agent_app_ctx, rcu_node);
+ lttng::utils::container_of(head, &agent_app_ctx::rcu_node);
destroy_app_ctx(ctx);
}
* value is not important since we have to continue anyway
* destroying the object.
*/
- event = caa_container_of(node, struct agent_event, node);
+ event = lttng::utils::container_of(node, &agent_event::node);
(void) agent_disable_event(event, agt->domain);
ret = lttng_ht_del(agt->events, &iter);
call_rcu(&ctx->rcu_node, destroy_app_ctx_rcu);
}
rcu_read_unlock();
- ht_cleanup_push(agt->events);
+ lttng_ht_destroy(agt->events);
free(agt);
}
the_agent_apps_ht_by_sock->ht, &iter.iter, node, node) {
struct agent_app *app;
- app = caa_container_of(node, struct agent_app, node);
+ app = lttng::utils::container_of(node, &agent_app::node);
agent_destroy_app_by_sock(app->sock->fd);
}
rcu_read_unlock();
cds_lfht_for_each_entry(the_trigger_agents_ht_by_domain->ht,
&iter.iter, node, node) {
struct agent *agent =
- caa_container_of(node, struct agent, node);
+ lttng::utils::container_of(node, &agent::node);
const int ret = lttng_ht_del(
the_trigger_agents_ht_by_domain, &iter);
goto end;
}
- agt = caa_container_of(node, struct agent, node);
+ agt = lttng::utils::container_of(node, &agent::node);
end:
return agt;