Handle the inactive streams
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 27 Nov 2013 16:40:10 +0000 (11:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Nov 2013 17:39:49 +0000 (12:39 -0500)
When content_size == 0, just set the timestamp_end of the packet and
reinsert the stream in the heap.
This is required to handle the beacons of inactivity generated in
LTTng live trace streaming.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c
lib/iterator.c

index 794e428c51d069a97354826b17f0f391afbafcbf..5f263cd36e9a50bae29981ba1d9daba24920c62d 100644 (file)
@@ -471,6 +471,11 @@ int ctf_read_event(struct bt_stream_pos *ppos, struct ctf_stream_definition *str
         */
        if (unlikely(pos->offset == EOF))
                return EOF;
+
+       if (pos->content_size == 0) {
+               /* Stream is inactive for now (live reading). */
+               return EAGAIN;
+       }
        assert(pos->offset < pos->content_size);
 
        /* Read event header */
index 009fcd3fecf0b502e19a4719225d470fd4719c7d..155fcbe6f7382a332ba3967e0cde86b21f5b40f7 100644 (file)
@@ -65,6 +65,9 @@ static int stream_read_event(struct ctf_file_stream *sin)
        ret = sin->pos.parent.event_cb(&sin->pos.parent, &sin->parent);
        if (ret == EOF)
                return EOF;
+       else if (ret == EAGAIN)
+               /* Stream is inactive for now (live reading). */
+               return EAGAIN;
        else if (ret) {
                fprintf(stderr, "[error] Reading event failed.\n");
                return ret;
@@ -803,9 +806,17 @@ int bt_iter_next(struct bt_iter *iter)
                assert(removed == file_stream);
                ret = 0;
                goto end;
+       } else if (ret == EAGAIN) {
+               /*
+                * The stream is inactive for now, we just updated the timestamp_end
+                * to skip over this stream up to a certain point in time.
+                */
+               goto reinsert;
        } else if (ret) {
                goto end;
        }
+
+reinsert:
        /* Reinsert the file stream into the heap, and rebalance. */
        removed = bt_heap_replace_max(iter->stream_heap, file_stream);
        assert(removed == file_stream);
This page took 0.026897 seconds and 4 git commands to generate.