From 5d2a5af291195537c5a589e388ddf2e2747fd6c5 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Thu, 14 Jun 2012 08:09:44 -0400 Subject: [PATCH] Fix babeltrace iterator lib: seek at time 0 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 Signed-off-by: Mathieu Desnoyers --- lib/iterator.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/iterator.c b/lib/iterator.c index 784166f2..e3ae0689 100644 --- a/lib/iterator.c +++ b/lib/iterator.c @@ -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; -- 2.34.1