X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fagent.c;h=35f0e578a0da725863f1b07be9d385a577371ea2;hp=f230c3619d43c9deae4c6d321e357194dc1b18b2;hb=890d8fe47755c3bad936389cf48ffa141cff41c9;hpb=2106efa08d11229241a114d1d71635a02006690e diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index f230c3619..35f0e578a 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -15,7 +15,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -103,6 +102,7 @@ static int ht_match_event(struct cds_lfht_node *node, { struct agent_event *event; const struct agent_ht_key *key; + int ll_match; assert(node); assert(_key); @@ -117,15 +117,15 @@ static int ht_match_event(struct cds_lfht_node *node, goto no_match; } - if (event->loglevel_value != key->loglevel_value) { - if (event->loglevel_type == LTTNG_EVENT_LOGLEVEL_ALL && - key->loglevel_value == 0 && - event->loglevel_value == -1) { - goto match; - } + /* Event loglevel value and type. */ + ll_match = loglevels_match(event->loglevel_type, + event->loglevel_value, key->loglevel_type, + key->loglevel_value, LTTNG_EVENT_LOGLEVEL_ALL); + + if (!ll_match) { goto no_match; } -match: + return 1; no_match: @@ -147,6 +147,7 @@ static void add_unique_agent_event(struct lttng_ht *ht, key.name = event->name; key.loglevel_value = event->loglevel_value; + key.loglevel_type = event->loglevel_type; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(event->node.key, lttng_ht_seed), @@ -827,12 +828,13 @@ error: * Return a new object else NULL on error. */ struct agent_event *agent_create_event(const char *name, - int loglevel_value, enum lttng_loglevel_type loglevel_type, + enum lttng_loglevel_type loglevel_type, int loglevel_value, struct lttng_filter_bytecode *filter, char *filter_expression) { struct agent_event *event = NULL; - DBG3("Agent create new event with name %s", name); + DBG3("Agent create new event with name %s, loglevel type %d and loglevel value %d", + name, loglevel_type, loglevel_value); if (!name) { ERR("Failed to create agent event; no name provided."); @@ -871,50 +873,59 @@ void agent_add_event(struct agent_event *event, struct agent *agt) } /* - * Find a agent event in the given agent using name. + * Find multiple agent events sharing the given name. * - * RCU read side lock MUST be acquired. + * RCU read side lock MUST be acquired. It must be held for the + * duration of the iteration. * - * Return object if found else NULL. + * Sets the given iterator. */ -struct agent_event *agent_find_event_by_name(const char *name, - struct agent *agt) +void agent_find_events_by_name(const char *name, struct agent *agt, + struct lttng_ht_iter* iter) { - struct lttng_ht_node_str *node; - struct lttng_ht_iter iter; struct lttng_ht *ht; struct agent_ht_key key; assert(name); assert(agt); assert(agt->events); + assert(iter); ht = agt->events; key.name = name; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), - ht_match_event_by_name, &key, &iter.iter); - node = lttng_ht_iter_get_node_str(&iter); - if (node == NULL) { - goto error; - } + ht_match_event_by_name, &key, &iter->iter); +} - DBG3("Agent event found %s by name.", name); - return caa_container_of(node, struct agent_event, node); +/* + * Get the next agent event duplicate by name. This should be called + * after a call to agent_find_events_by_name() to iterate on events. + * + * The RCU read lock must be held during the iteration and for as long + * as the object the iterator points to remains in use. + */ +void agent_event_next_duplicate(const char *name, + struct agent *agt, struct lttng_ht_iter* iter) +{ + struct agent_ht_key key; -error: - DBG3("Agent NOT found by name %s.", name); - return NULL; + key.name = name; + + cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name, + &key, &iter->iter); } /* * Find a agent event in the given agent using name and loglevel. * - * RCU read side lock MUST be acquired. + * RCU read side lock MUST be acquired. It must be kept for as long as + * the returned agent_event is used. * * Return object if found else NULL. */ -struct agent_event *agent_find_event(const char *name, int loglevel_value, +struct agent_event *agent_find_event(const char *name, + enum lttng_loglevel_type loglevel_type, int loglevel_value, struct agent *agt) { struct lttng_ht_node_str *node; @@ -929,6 +940,7 @@ struct agent_event *agent_find_event(const char *name, int loglevel_value, ht = agt->events; key.name = name; key.loglevel_value = loglevel_value; + key.loglevel_type = loglevel_type; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), ht_match_event, &key, &iter.iter);