Fix babeltrace iterator lib: seek at time 0
authorJulien Desfossez <julien.desfossez@efficios.com>
Thu, 14 Jun 2012 12:09:44 +0000 (08:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Jun 2012 12:09:44 +0000 (08:09 -0400)
When seeking by timestamp, we assumed that the timestamp passed as an
argument was a real timestamp from the trace. However LTTV uses
timestamp 0 to refer to the beginning of the trace. This fix ensures
that we read at least the first event after the seek.

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

index 784166f2bf167caa672144716df4aa5dde315832..e3ae0689d80ce429da64748f0d7866536900f01b 100644 (file)
@@ -118,11 +118,10 @@ static int seek_file_stream_by_timestamp(struct ctf_file_stream *cfs,
                        continue;
 
                stream_pos->packet_seek(&stream_pos->parent, i, SEEK_SET);
-               while (cfs->parent.timestamp < timestamp) {
+               do {
                        ret = stream_read_event(cfs);
-                       if (ret < 0)
-                               break;
-               }
+               } while (cfs->parent.timestamp < timestamp && ret >= 0);
+
                return 0;
        }
        return EOF;
This page took 0.024872 seconds and 4 git commands to generate.