Fix: include loglevel type in agent event's primary key
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 2 Sep 2015 05:54:23 +0000 (01:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Sep 2015 14:00:35 +0000 (10:00 -0400)
Refs: #913

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/agent.c
src/bin/lttng-sessiond/agent.h
src/bin/lttng-sessiond/event.c

index 8515b005a8d46cad8fdcb8e88d763350d16e252b..7797f8c26b57edd869ad651fcb31b175fbba4604 100644 (file)
@@ -79,15 +79,23 @@ 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. */
+       if (event->loglevel_type == key->loglevel_type) {
+               /* Same loglevel type. */
+               if (key->loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
+                       /*
+                        * Loglevel value must also match since the loglevel
+                        * type is not all.
+                        */
+                       if (event->loglevel_value != key->loglevel_value) {
+                               goto no_match;
+                       }
                }
+       } else {
+               /* Loglevel type is different: no match. */
                goto no_match;
        }
-match:
+
        return 1;
 
 no_match:
@@ -109,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;
 
        node_ptr = cds_lfht_add_unique(ht->ht,
                        ht->hash_fct(event->node.key, lttng_ht_seed),
@@ -791,12 +800,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.");
@@ -881,7 +891,8 @@ error:
  *
  * 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;
@@ -896,6 +907,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);
index da51f017630f9c34c22633874065824697a44f60..fd1c47f3f1150e8f9950f51a3eadc0b77c0e732f 100644 (file)
@@ -37,6 +37,7 @@ struct lttng_ht *agent_apps_ht_by_sock;
 struct agent_ht_key {
        const char *name;
        int loglevel_value;
+       enum lttng_loglevel_type loglevel_type;
 };
 
 /*
@@ -131,13 +132,14 @@ void agent_destroy(struct agent *agt);
 void agent_add(struct agent *agt, struct lttng_ht *ht);
 
 /* Agent event API. */
-struct agent_event *agent_create_event(const char *name, int loglevel,
-               enum lttng_loglevel_type loglevel_type,
+struct agent_event *agent_create_event(const char *name,
+               enum lttng_loglevel_type loglevel_type, int loglevel_value,
                struct lttng_filter_bytecode *filter,
                char *filter_expression);
 void agent_add_event(struct agent_event *event, struct agent *agt);
 
-struct agent_event *agent_find_event(const char *name, int loglevel,
+struct agent_event *agent_find_event(const char *name,
+               enum lttng_loglevel_type loglevel_type, int loglevel_value,
                struct agent *agt);
 struct agent_event *agent_find_event_by_name(const char *name,
                struct agent *agt);
index 1c3166ed3ee17f1d4f3ff567fb1dde2098eb2284..27ebc4ff3cb3fd86aa17c929247aa3b4b7a210e2 100644 (file)
@@ -411,10 +411,11 @@ int event_agent_enable(struct ltt_ust_session *usess,
                        usess->id, event->loglevel_type, event->loglevel,
                        filter_expression ? filter_expression : "NULL");
 
-       aevent = agent_find_event(event->name, event->loglevel, agt);
+       aevent = agent_find_event(event->name, event->loglevel_type,
+               event->loglevel, agt);
        if (!aevent) {
-               aevent = agent_create_event(event->name, event->loglevel,
-                               event->loglevel_type, filter,
+               aevent = agent_create_event(event->name, event->loglevel_type,
+                               event->loglevel, filter,
                                filter_expression);
                if (!aevent) {
                        ret = LTTNG_ERR_NOMEM;
This page took 0.027738 seconds and 4 git commands to generate.