Fix events listing using the channel name
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 23 Nov 2011 21:28:17 +0000 (16:28 -0500)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 23 Nov 2011 21:28:17 +0000 (16:28 -0500)
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
lttng-sessiond/main.c

index 4bb7240378161540cb4573e4a3fc91e076dbdbae..988cb57c3910d3421c79d53b28ce61fda8edd6f6 100644 (file)
@@ -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;
This page took 0.029108 seconds and 4 git commands to generate.