Cleanup: ust_session_id unused by buffer_reg_uid_consumer_channel_key
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.c
index 10758f9b8534ce26b65cce19a870e2ed82e11e45..5db920781b5009d1a0b2b462e8e96c2825c24243 100644 (file)
@@ -15,7 +15,6 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <inttypes.h>
 
@@ -74,10 +73,10 @@ no_match:
  * Hash function for the per UID registry hash table. This XOR the triplet
  * together.
  */
-static unsigned long ht_hash_reg_uid(void *_key, unsigned long seed)
+static unsigned long ht_hash_reg_uid(const void *_key, unsigned long seed)
 {
        uint64_t xored_key;
-       struct buffer_reg_uid *key = _key;
+       const struct buffer_reg_uid *key = _key;
 
        assert(key);
 
@@ -328,6 +327,43 @@ end:
        return reg;
 }
 
+/*
+ * Find the consumer channel key from a UST session per-uid channel key.
+ *
+ * Return the matching key or -1 if not found.
+ */
+int buffer_reg_uid_consumer_channel_key(
+               struct cds_list_head *buffer_reg_uid_list,
+               uint64_t chan_key, uint64_t *consumer_chan_key)
+{
+       struct lttng_ht_iter iter;
+       struct buffer_reg_uid *uid_reg = NULL;
+       struct buffer_reg_session *session_reg = NULL;
+       struct buffer_reg_channel *reg_chan;
+       int ret = -1;
+
+       rcu_read_lock();
+       /*
+        * For the per-uid registry, we have to iterate since we don't have the
+        * uid and bitness key.
+        */
+       cds_list_for_each_entry(uid_reg, buffer_reg_uid_list, lnode) {
+               session_reg = uid_reg->registry;
+               cds_lfht_for_each_entry(session_reg->channels->ht,
+                               &iter.iter, reg_chan, node.node) {
+                       if (reg_chan->key == chan_key) {
+                               *consumer_chan_key = reg_chan->consumer_key;
+                               ret = 0;
+                               goto end;
+                       }
+               }
+       }
+
+end:
+       rcu_read_unlock();
+       return ret;
+}
+
 /*
  * Allocate and initialize a buffer registry channel with the given key. Set
  * regp with the object pointer.
This page took 0.02414 seconds and 4 git commands to generate.