X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fagent.cpp;h=08785235623d5d312d14b95960c1efaaac003f68;hb=64803277bbdbe0a943360d918298a48157d9da55;hp=620ec787f01833b9ed1e9d9899d3d8755fe44397;hpb=3c3390532736cfb5198f863d0d2b218e21fcf76d;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/agent.cpp b/src/bin/lttng-sessiond/agent.cpp index 620ec787f..087852356 100644 --- a/src/bin/lttng-sessiond/agent.cpp +++ b/src/bin/lttng-sessiond/agent.cpp @@ -11,24 +11,24 @@ #include #include -#include +#include #include #include #include #include #include -#include -#include +#include +#include -#include -#include +#include +#include -#include +#include -#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); @@ -348,7 +348,7 @@ static ssize_t list_events(struct agent_app *app, struct lttng_event **events) goto error; } - reply = (lttcomm_agent_list_reply *) zmalloc(data_size); + reply = zmalloc(data_size); if (!reply) { ret = LTTNG_ERR_NOMEM; goto error; @@ -361,7 +361,7 @@ static ssize_t list_events(struct agent_app *app, struct lttng_event **events) } nb_event = be32toh(reply->nb_event); - tmp_events = (lttng_event *) zmalloc(sizeof(*tmp_events) * nb_event); + tmp_events = calloc(nb_event); if (!tmp_events) { ret = LTTNG_ERR_NOMEM; goto error; @@ -441,7 +441,7 @@ static int enable_event(const struct agent_app *app, struct agent_event *event) goto error_io; } - bytes_to_send = (char *) zmalloc(data_size); + bytes_to_send = calloc(data_size); if (!bytes_to_send) { ret = LTTNG_ERR_NOMEM; goto error; @@ -726,7 +726,7 @@ struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx) } LTTNG_ASSERT(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT); - agent_ctx = (agent_app_ctx *) zmalloc(sizeof(*ctx)); + agent_ctx = zmalloc(); if (!agent_ctx) { goto end; } @@ -898,7 +898,7 @@ int agent_list_events(struct lttng_event **events, 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(nbmem); if (!tmp_events) { PERROR("zmalloc agent list events"); ret = -ENOMEM; @@ -974,7 +974,7 @@ struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain, LTTNG_ASSERT(sock); - app = (agent_app *) zmalloc(sizeof(*app)); + app = zmalloc(); if (!app) { PERROR("Failed to allocate agent application instance"); goto error; @@ -1003,6 +1003,7 @@ struct agent_app *agent_find_app_by_sock(int sock) 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); @@ -1042,6 +1043,7 @@ void agent_delete_app(struct agent_app *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); @@ -1115,7 +1117,7 @@ struct agent *agent_create(enum lttng_domain_type domain) int ret; struct agent *agt; - agt = (agent *) zmalloc(sizeof(struct agent)); + agt = zmalloc(); if (!agt) { goto error; } @@ -1154,7 +1156,7 @@ struct agent_event *agent_create_event(const char *name, goto error; } - event = (agent_event *) zmalloc(sizeof(*event)); + event = zmalloc(); if (!event) { goto error; } @@ -1229,6 +1231,7 @@ void agent_find_events_by_name(const char *name, struct agent *agt, LTTNG_ASSERT(agt); LTTNG_ASSERT(agt->events); LTTNG_ASSERT(iter); + ASSERT_RCU_READ_LOCKED(); ht = agt->events; key.name = name; @@ -1264,6 +1267,7 @@ struct agent_event *agent_find_event_by_trigger( LTTNG_ASSERT(agt); LTTNG_ASSERT(agt->events); + ASSERT_RCU_READ_LOCKED(); condition = lttng_trigger_get_const_condition(trigger); @@ -1336,6 +1340,8 @@ void agent_event_next_duplicate(const char *name, { struct agent_ht_key key; + ASSERT_RCU_READ_LOCKED(); + key.name = name; cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name, @@ -1364,6 +1370,7 @@ struct agent_event *agent_find_event(const char *name, LTTNG_ASSERT(name); LTTNG_ASSERT(agt); LTTNG_ASSERT(agt->events); + ASSERT_RCU_READ_LOCKED(); ht = agt->events; key.name = name;