Validate channel context mismatch across UST applications
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry.c
index 7faf8b128bc9baba7941ec781b24ac0b475df501..5d2487cd2eca63f8de2d5bd08ea752daaea851a4 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _LGPL_SOURCE
@@ -30,7 +20,6 @@
 #include "lttng-sessiond.h"
 #include "notification-thread-commands.h"
 
-
 /*
  * Hash table match function for event in the registry.
  */
@@ -38,7 +27,6 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key)
 {
        const struct ust_registry_event *key;
        struct ust_registry_event *event;
-       int i;
 
        assert(node);
        assert(_key);
@@ -57,18 +45,12 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key)
                goto no_match;
        }
 
-       /* Compare the number of fields. */
-       if (event->nr_fields != key->nr_fields) {
+       /* Compare the arrays of fields. */
+       if (!match_lttng_ust_ctl_field_array(event->fields, event->nr_fields,
+                       key->fields, key->nr_fields)) {
                goto no_match;
        }
 
-       /* Compare each field individually. */
-       for (i = 0; i < event->nr_fields; i++) {
-               if (!match_ustctl_field(&event->fields[i], &key->fields[i])) {
-                       goto no_match;
-               }
-       }
-
        /* Compare model URI. */
        if (event->model_emf_uri != NULL && key->model_emf_uri == NULL) {
                goto no_match;
@@ -738,13 +720,16 @@ static void destroy_channel(struct ust_registry_channel *chan, bool notif)
                }
        }
 
-       rcu_read_lock();
-       /* Destroy all event associated with this registry. */
-       cds_lfht_for_each_entry(chan->ht->ht, &iter.iter, event, node.node) {
-               /* Delete the node from the ht and free it. */
-               ust_registry_destroy_event(chan, event);
+       if (chan->ht) {
+               rcu_read_lock();
+               /* Destroy all event associated with this registry. */
+               cds_lfht_for_each_entry(
+                               chan->ht->ht, &iter.iter, event, node.node) {
+                       /* Delete the node from the ht and free it. */
+                       ust_registry_destroy_event(chan, event);
+               }
+               rcu_read_unlock();
        }
-       rcu_read_unlock();
        call_rcu(&chan->rcu_head, destroy_channel_rcu);
 }
 
This page took 0.024122 seconds and 4 git commands to generate.