Fix order of streams
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 5 Nov 2011 15:27:53 +0000 (11:27 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 5 Nov 2011 15:27:53 +0000 (11:27 -0400)
Use a list instead of hash table to send streams in correct order.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/lttng-consumer.h
liblttng-consumer/lttng-consumer.c
lttng-sessiond/trace-ust.h
lttng-sessiond/ust-app.c
lttng-sessiond/ust-app.h
lttng-sessiond/ust-consumer.c

index 7751570efef38cfde7319b97bb3f114381c7b793..1a6afc22aedd2e8a89d3ed852b43a0b472d62689 100644 (file)
@@ -85,6 +85,7 @@ struct lttng_consumer_channel {
        int nr_streams;
        int shm_fd_is_copy;
        int wait_fd_is_copy;
+       int cpucount;
 };
 
 /* Forward declaration for UST. */
index 5311860e01ac3d5c145991c194d3f3a32060d96f..2fcb39a27290ea2d1f9a060948df6252698deaf8 100644 (file)
@@ -181,6 +181,7 @@ struct lttng_consumer_stream *consumer_allocate_stream(
        case LTTNG_CONSUMER_KERNEL:
                break;
        case LTTNG_CONSUMER_UST:
+               stream->cpu = stream->chan->cpucount++;
                ret = lttng_ustconsumer_allocate_stream(stream);
                if (ret) {
                        free(stream);
index 35683ebce6b95970694da76d7d74de34be36a8e0..604024b18b00f7e56c4da266ef9ea518096c4307 100644 (file)
@@ -53,7 +53,8 @@ struct ltt_ust_stream {
        int handle;
        char pathname[PATH_MAX];
        struct lttng_ust_object_data *obj;
-       struct cds_lfht_node node;
+       /* Using a list of streams to keep order. */
+       struct cds_list_head list;
 };
 
 /* UST channel */
index bce76f791315b43b07ff023cd530db130a9b2153..9e6b3468b61a6131e652bd3b9b38eb670ac81adf 100644 (file)
@@ -322,7 +322,7 @@ static struct ust_app_channel *alloc_app_channel(char *name)
        ua_chan->handle = -1;
        ua_chan->obj = NULL;
        ua_chan->ctx = hashtable_new(0);
-       ua_chan->streams = hashtable_new(0);
+       CDS_INIT_LIST_HEAD(&ua_chan->streams.head);
        ua_chan->events = hashtable_new_str(0);
        hashtable_node_init(&ua_chan->node, (void *) ua_chan->name,
                        strlen(ua_chan->name));
@@ -788,12 +788,11 @@ int ust_app_start_trace(struct ltt_ust_session *usess)
                                memset(ustream, 0, sizeof(struct ltt_ust_stream));
                                ustream->obj = obj;
                                ustream->handle = ustream->obj->handle;
-                               hashtable_node_init(&ustream->node,
-                                       (void *)((unsigned long) ustream->handle), sizeof(void *));
-                               hashtable_add_unique(ua_chan->streams, &ustream->node);
-                               ret = snprintf(ustream->pathname, PATH_MAX, "%s/%s_%lu",
+                               /* Order is important */
+                               cds_list_add_tail(&ustream->list, &ua_chan->streams.head);
+                               ret = snprintf(ustream->pathname, PATH_MAX, "%s/%s_%u",
                                                uchan->pathname, uchan->name,
-                                               hashtable_get_count(ua_chan->streams) - 1);
+                                               ua_chan->streams.count++);
                                if (ret < 0) {
                                        PERROR("asprintf UST create stream");
                                        goto next_chan;
index 04c3472dd6851e83bc9b71e3de16ead92241d3e0..9a30b6f8f58cca9d5a18bf67faf0adb8f82b4363 100644 (file)
@@ -65,7 +65,7 @@ struct ust_app_channel {
        char name[LTTNG_UST_SYM_NAME_LEN];
        struct lttng_ust_channel attr;
        struct lttng_ust_object_data *obj;
-       struct cds_lfht *streams;
+       struct ltt_ust_stream_list streams;
        struct cds_lfht *ctx;
        struct cds_lfht *events;
        struct cds_lfht_node node;
index 1e583839e4292c2befce109f7549dc76b5d51593..444ff6eeea9f6b79c1c93259890927b52a27bf28 100644 (file)
@@ -38,8 +38,7 @@ static int send_channel_streams(int sock,
 {
        int ret, fd;
        struct lttcomm_consumer_msg lum;
-       struct cds_lfht_iter iter;
-       struct cds_lfht_node *node;
+       struct ltt_ust_stream *stream;
 
        DBG("Sending streams of channel %s to UST consumer", uchan->name);
 
@@ -66,15 +65,11 @@ static int send_channel_streams(int sock,
                goto error;
        }
 
-       rcu_read_lock();
-       hashtable_get_first(uchan->streams, &iter);
-       while ((node = hashtable_iter_get_node(&iter)) != NULL) {
-               struct ltt_ust_stream *stream =
-                               caa_container_of(node, struct ltt_ust_stream, node);
+       cds_list_for_each_entry(stream, &uchan->streams.head, list) {
                int fds[2];
 
                if (!stream->obj->shm_fd) {
-                       goto next;
+                       continue;
                }
                lum.cmd_type = LTTNG_CONSUMER_ADD_STREAM;
                lum.u.stream.channel_key = uchan->obj->shm_fd;
@@ -98,11 +93,7 @@ static int send_channel_streams(int sock,
                        perror("send consumer stream ancillary data");
                        goto error;
                }
-
-next:
-               hashtable_get_next(uchan->streams, &iter);
        }
-       rcu_read_unlock();
 
        DBG("consumer channel streams sent");
 
This page took 0.030473 seconds and 5 git commands to generate.