X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry.cpp;h=effb319994e98a89cabf01f2ad97bad9e37fe8c3;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hp=17346520380b1d67673fd0dfc10c1fc7cf50e704;hpb=7966af5763c4aaca39df9bbfa9277ff15715c720;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-registry.cpp b/src/bin/lttng-sessiond/ust-registry.cpp index 173465203..effb31999 100644 --- a/src/bin/lttng-sessiond/ust-registry.cpp +++ b/src/bin/lttng-sessiond/ust-registry.cpp @@ -8,17 +8,16 @@ #define _LGPL_SOURCE #include -#include -#include +#include +#include #include -#include "ust-registry.h" -#include "ust-app.h" -#include "ust-field-utils.h" -#include "utils.h" -#include "lttng-sessiond.h" -#include "notification-thread-commands.h" - +#include "ust-registry.hpp" +#include "ust-app.hpp" +#include "ust-field-utils.hpp" +#include "utils.hpp" +#include "lttng-sessiond.hpp" +#include "notification-thread-commands.hpp" /* * Hash table match function for event in the registry. @@ -27,7 +26,6 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key) { const struct ust_registry_event *key; struct ust_registry_event *event; - int i; LTTNG_ASSERT(node); LTTNG_ASSERT(_key); @@ -46,18 +44,12 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key) goto no_match; } - /* Compare the number of fields. */ - if (event->nr_fields != key->nr_fields) { + /* Compare the arrays of fields. */ + if (!match_lttng_ust_ctl_field_array(event->fields, event->nr_fields, + key->fields, key->nr_fields)) { goto no_match; } - /* Compare each field individually. */ - for (i = 0; i < event->nr_fields; i++) { - if (!match_lttng_ust_ctl_field(&event->fields[i], &key->fields[i])) { - goto no_match; - } - } - /* Compare model URI. */ if (event->model_emf_uri != NULL && key->model_emf_uri == NULL) { goto no_match; @@ -323,7 +315,7 @@ error: /* * Free event data structure. This does NOT delete it from any hash table. It's - * safe to pass a NULL pointer. This shoudl be called inside a call RCU if the + * safe to pass a NULL pointer. This should be called inside a call RCU if the * event is previously deleted from a rcu hash table. */ static void destroy_event(struct ust_registry_event *event) @@ -369,6 +361,7 @@ struct ust_registry_event *ust_registry_find_event( LTTNG_ASSERT(chan); LTTNG_ASSERT(name); LTTNG_ASSERT(sig); + ASSERT_RCU_READ_LOCKED(); /* Setup key for the match function. */ strncpy(key.name, name, sizeof(key.name)); @@ -517,6 +510,7 @@ void ust_registry_destroy_event(struct ust_registry_channel *chan, LTTNG_ASSERT(chan); LTTNG_ASSERT(event); + ASSERT_RCU_READ_LOCKED(); /* Delete the node first. */ iter.iter.node = &event->node.node; @@ -557,6 +551,8 @@ static struct ust_registry_enum *ust_registry_lookup_enum( struct lttng_ht_node_str *node; struct lttng_ht_iter iter; + ASSERT_RCU_READ_LOCKED(); + cds_lfht_lookup(session->enums->ht, ht_hash_enum((void *) reg_enum_lookup, lttng_ht_seed), ht_match_enum, reg_enum_lookup, &iter.iter); @@ -582,6 +578,8 @@ struct ust_registry_enum * struct lttng_ht_iter iter; struct ust_registry_enum reg_enum_lookup; + ASSERT_RCU_READ_LOCKED(); + memset(®_enum_lookup, 0, sizeof(reg_enum_lookup)); strncpy(reg_enum_lookup.name, enum_name, LTTNG_UST_ABI_SYM_NAME_LEN); reg_enum_lookup.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0'; @@ -689,6 +687,7 @@ static void ust_registry_destroy_enum(struct ust_registry_session *reg_session, LTTNG_ASSERT(reg_session); LTTNG_ASSERT(reg_enum); + ASSERT_RCU_READ_LOCKED(); /* Delete the node first. */ iter.iter.node = ®_enum->node.node; @@ -697,12 +696,6 @@ static void ust_registry_destroy_enum(struct ust_registry_session *reg_session, call_rcu(®_enum->rcu_head, destroy_enum_rcu); } -/* - * We need to execute ht_destroy outside of RCU read-side critical - * section and outside of call_rcu thread, so we postpone its execution - * using ht_cleanup_push. It is simpler than to change the semantic of - * the many callers of delete_ust_app_session(). - */ static void destroy_channel_rcu(struct rcu_head *head) { @@ -710,7 +703,7 @@ void destroy_channel_rcu(struct rcu_head *head) caa_container_of(head, struct ust_registry_channel, rcu_head); if (chan->ht) { - ht_cleanup_push(chan->ht); + lttng_ht_destroy(chan->ht); } free(chan->ctx_fields); free(chan); @@ -819,6 +812,7 @@ struct ust_registry_channel *ust_registry_channel_find( LTTNG_ASSERT(session); LTTNG_ASSERT(session->channels); + ASSERT_RCU_READ_LOCKED(); DBG3("UST registry channel finding key %" PRIu64, key); @@ -1019,7 +1013,7 @@ void ust_registry_session_destroy(struct ust_registry_session *reg) destroy_channel(chan, true); } rcu_read_unlock(); - ht_cleanup_push(reg->channels); + lttng_ht_destroy(reg->channels); } free(reg->metadata); @@ -1051,6 +1045,6 @@ void ust_registry_session_destroy(struct ust_registry_session *reg) ust_registry_destroy_enum(reg, reg_enum); } rcu_read_unlock(); - ht_cleanup_push(reg->enums); + lttng_ht_destroy(reg->enums); } }