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.7.1~10 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ade8d7e3958921c9ef668c17d877eaf8d5b14f3a;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 eed7e68c6..e9cd5fa05 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -89,6 +89,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: @@ -111,6 +117,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), @@ -798,8 +805,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."); @@ -885,7 +893,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. * @@ -893,7 +901,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; @@ -908,6 +916,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 49393e809..2f3a6b95f 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -38,6 +38,7 @@ struct agent_ht_key { const char *name; int loglevel_value; enum lttng_loglevel_type loglevel_type; + char *filter_expression; }; /* @@ -140,7 +141,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 589d88eac..3606a2a6a 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,