X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fbuffer-registry.c;h=7002b33c7b2969bca7ce97f04b2ffd64ecd394a6;hp=7fbe3565b85d509d30db5561fedf743d4becde00;hb=fb83fe64f250bec7416f18891a8264450c61ead3;hpb=53e367f936beb2f9a1f49f6a2920c2f58bcb08d7 diff --git a/src/bin/lttng-sessiond/buffer-registry.c b/src/bin/lttng-sessiond/buffer-registry.c index 7fbe3565b..7002b33c7 100644 --- a/src/bin/lttng-sessiond/buffer-registry.c +++ b/src/bin/lttng-sessiond/buffer-registry.c @@ -327,6 +327,44 @@ 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 usess_id, 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.