From a5b7e00cc0c98737587c53f205119ca6411fdcd4 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 26 Aug 2015 01:47:15 -0400 Subject: [PATCH 1/1] Ignore exclusion names order when matching events MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In other words: lttng enable-event -u -a --exclude a,b,c,d -> passes lttng enable-event -u -a --exclude a,c,d,b -> fails (same event) Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/trace-ust.c | 42 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 4b7363f9f..1ddd597cf 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -116,12 +116,46 @@ int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key) } if (key->exclusion && event->exclusion) { - /* Both exclusions exist; check count followed by names. */ - if (event->exclusion->count != key->exclusion->count || - memcmp(event->exclusion->names, key->exclusion->names, - event->exclusion->count * LTTNG_SYMBOL_NAME_LEN) != 0) { + size_t i; + + /* Check exclusion counts first. */ + if (event->exclusion->count != key->exclusion->count) { goto no_match; } + + /* Compare names individually. */ + for (i = 0; i < event->exclusion->count; ++i) { + size_t j; + bool found = false; + const char *name_ev = + LTTNG_EVENT_EXCLUSION_NAME_AT( + event->exclusion, i); + + /* + * Compare this exclusion name to all the key's + * exclusion names. + */ + for (j = 0; j < key->exclusion->count; ++j) { + const char *name_key = + LTTNG_EVENT_EXCLUSION_NAME_AT( + key->exclusion, j); + + if (!strncmp(name_ev, name_key, + LTTNG_SYMBOL_NAME_LEN)) { + /* Names match! */ + found = true; + break; + } + } + + /* + * If the current exclusion name was not found amongst + * the key's exclusion names, then there's no match. + */ + if (!found) { + goto no_match; + } + } } /* Match. */ return 1; -- 2.34.1