Handle empty streams on iterator init
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 27 Nov 2013 16:40:12 +0000 (11:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 27 Nov 2013 17:40:56 +0000 (12:40 -0500)
In live trace streaming, we can create an iterator with inactive
streams. This patch allows inactive streams to be considered as valid.

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

index 155fcbe6f7382a332ba3967e0cde86b21f5b40f7..3280f4a816c3a88468dfb99dd320111c24ded54d 100644 (file)
@@ -725,7 +725,7 @@ int bt_iter_init(struct bt_iter *iter,
                                if (ret == EOF) {
                                        ret = 0;
                                        continue;
-                               } else if (ret) {
+                               } else if (ret != 0 && ret != EAGAIN) {
                                        goto error;
                                }
                                /* Add to heap */
@@ -821,6 +821,13 @@ reinsert:
        removed = bt_heap_replace_max(iter->stream_heap, file_stream);
        assert(removed == file_stream);
 
+       file_stream = bt_heap_maximum(iter->stream_heap);
+       if (file_stream->pos.content_size == 0) {
+               ret = EAGAIN;
+       } else {
+               ret = 0;
+       }
+
 end:
        return ret;
 }
This page took 0.025463 seconds and 4 git commands to generate.