From d7b75b30d1f70dab2d5bca42cff86290c938c516 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 23 Nov 2011 16:28:17 -0500 Subject: [PATCH] Fix events listing using the channel name Signed-off-by: David Goulet --- lttng-sessiond/main.c | 45 ++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index 4bb724037..988cb57c3 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -1941,6 +1941,7 @@ static int list_lttng_ust_global_events(char *channel_name, int i = 0, ret = 0; unsigned int nb_event = 0; struct cds_lfht_iter iter; + struct cds_lfht_node *node; struct ltt_ust_channel *uchan; struct ltt_ust_event *uevent; struct lttng_event *tmp; @@ -1949,11 +1950,17 @@ static int list_lttng_ust_global_events(char *channel_name, rcu_read_lock(); - /* Count events in all channels */ - cds_lfht_for_each_entry(ust_global->channels, &iter, uchan, node) { - nb_event += hashtable_get_count(uchan->events); + node = hashtable_lookup(ust_global->channels, (void *) channel_name, + strlen(channel_name), &iter); + if (node == NULL) { + ret = -LTTCOMM_UST_CHAN_NOT_FOUND; + goto error; } + uchan = caa_container_of(node, struct ltt_ust_channel, node); + + nb_event += hashtable_get_count(uchan->events); + if (nb_event == 0) { ret = nb_event; goto error; @@ -1967,24 +1974,22 @@ static int list_lttng_ust_global_events(char *channel_name, goto error; } - cds_lfht_for_each_entry(ust_global->channels, &iter, uchan, node) { - cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) { - strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN); - tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; - tmp[i].enabled = uevent->enabled; - switch (uevent->attr.instrumentation) { - case LTTNG_UST_TRACEPOINT: - tmp[i].type = LTTNG_EVENT_TRACEPOINT; - break; - case LTTNG_UST_PROBE: - tmp[i].type = LTTNG_EVENT_PROBE; - break; - case LTTNG_UST_FUNCTION: - tmp[i].type = LTTNG_EVENT_FUNCTION; - break; - } - i++; + cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) { + strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN); + tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; + tmp[i].enabled = uevent->enabled; + switch (uevent->attr.instrumentation) { + case LTTNG_UST_TRACEPOINT: + tmp[i].type = LTTNG_EVENT_TRACEPOINT; + break; + case LTTNG_UST_PROBE: + tmp[i].type = LTTNG_EVENT_PROBE; + break; + case LTTNG_UST_FUNCTION: + tmp[i].type = LTTNG_EVENT_FUNCTION; + break; } + i++; } ret = nb_event; -- 2.34.1