From: Alexandre Montplaisir Date: Fri, 11 Sep 2015 22:38:52 +0000 (-0400) Subject: Fix: include the filter expression in agent events' primary key X-Git-Tag: v2.8.0-rc1~243 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6b10b3b01eb754c0c3149490f700763dbac60ed5;p=lttng-tools.git Fix: include the filter expression in agent events' primary key Similar fix to a931962, but for filter expressions this time. UST events's key already includes the filter bytecode, so adding the string itself should not be needed. Signed-off-by: Alexandre Montplaisir Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index def13707b..5380cd8e4 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -126,6 +126,12 @@ static int ht_match_event(struct cds_lfht_node *node, goto no_match; } + /* Filter expression */ + if (strncmp(event->filter_expression, key->filter_expression, + strlen(event->filter_expression)) != 0) { + goto no_match; + } + return 1; no_match: @@ -148,6 +154,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; + key.filter_expression = event->filter_expression; node_ptr = cds_lfht_add_unique(ht->ht, ht->hash_fct(event->node.key, lttng_ht_seed), @@ -859,8 +866,9 @@ struct agent_event *agent_create_event(const char *name, { struct agent_event *event = NULL; - DBG3("Agent create new event with name %s, loglevel type %d and loglevel value %d", - name, loglevel_type, loglevel_value); + DBG3("Agent create new event with name %s, loglevel type %d, \ + loglevel value %d and filter %s", + name, loglevel_type, loglevel_value, filter_expression); if (!name) { ERR("Failed to create agent event; no name provided."); @@ -943,7 +951,7 @@ void agent_event_next_duplicate(const char *name, } /* - * Find a agent event in the given agent using name and loglevel. + * Find a agent event in the given agent using name, loglevel and filter. * * RCU read side lock MUST be acquired. It must be kept for as long as * the returned agent_event is used. @@ -952,7 +960,7 @@ void agent_event_next_duplicate(const char *name, */ struct agent_event *agent_find_event(const char *name, enum lttng_loglevel_type loglevel_type, int loglevel_value, - struct agent *agt) + char *filter_expression, struct agent *agt) { struct lttng_ht_node_str *node; struct lttng_ht_iter iter; @@ -967,6 +975,7 @@ struct agent_event *agent_find_event(const char *name, key.name = name; key.loglevel_value = loglevel_value; key.loglevel_type = loglevel_type; + key.filter_expression = filter_expression; cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed), ht_match_event, &key, &iter.iter); diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h index af8254e1b..2b3d864a6 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -37,6 +37,7 @@ struct agent_ht_key { const char *name; int loglevel_value; enum lttng_loglevel_type loglevel_type; + char *filter_expression; }; /* @@ -139,7 +140,7 @@ void agent_add_event(struct agent_event *event, struct agent *agt); struct agent_event *agent_find_event(const char *name, enum lttng_loglevel_type loglevel_type, int loglevel_value, - struct agent *agt); + char *filter_expression, struct agent *agt); void agent_find_events_by_name(const char *name, struct agent *agt, struct lttng_ht_iter* iter); void agent_event_next_duplicate(const char *name, diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index c0e2014ae..e4c79df74 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -439,7 +439,7 @@ int event_agent_enable(struct ltt_ust_session *usess, filter_expression ? filter_expression : "NULL"); aevent = agent_find_event(event->name, event->loglevel_type, - event->loglevel, agt); + event->loglevel, filter_expression, agt); if (!aevent) { aevent = agent_create_event(event->name, event->loglevel_type, event->loglevel, filter,