Fix: test content size vs headers len
[babeltrace.git] / lib / iterator.c
index dc12a2f41020d34fa4903bc61494bddb092e53c7..009fcd3fecf0b502e19a4719225d470fd4719c7d 100644 (file)
@@ -73,16 +73,24 @@ static int stream_read_event(struct ctf_file_stream *sin)
 }
 
 /*
- * returns true if a < b, false otherwise.
+ * Return true if a < b, false otherwise.
+ * If time stamps are exactly the same, compare by stream path. This
+ * ensures we get the same result between runs on the same trace
+ * collection on different environments.
+ * The result will be random for memory-mapped traces since there is no
+ * fixed path leading to those (they have empty path string).
  */
 static int stream_compare(void *a, void *b)
 {
        struct ctf_file_stream *s_a = a, *s_b = b;
 
-       if (s_a->parent.real_timestamp < s_b->parent.real_timestamp)
+       if (s_a->parent.real_timestamp < s_b->parent.real_timestamp) {
                return 1;
-       else
+       } else if (likely(s_a->parent.real_timestamp > s_b->parent.real_timestamp)) {
                return 0;
+       } else {
+               return strcmp(s_a->parent.path, s_b->parent.path);
+       }
 }
 
 void bt_iter_free_pos(struct bt_iter_pos *iter_pos)
@@ -309,7 +317,7 @@ static int seek_last_ctf_trace_collection(struct trace_collection *tc,
        /* For each trace in the trace_collection */
        for (i = 0; i < tc->array->len; i++) {
                struct ctf_trace *tin;
-               struct trace_descriptor *td_read;
+               struct bt_trace_descriptor *td_read;
 
                td_read = g_ptr_array_index(tc->array, i);
                if (!td_read)
@@ -421,7 +429,7 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
                /* for each trace in the trace_collection */
                for (i = 0; i < tc->array->len; i++) {
                        struct ctf_trace *tin;
-                       struct trace_descriptor *td_read;
+                       struct bt_trace_descriptor *td_read;
 
                        td_read = g_ptr_array_index(tc->array, i);
                        if (!td_read)
@@ -451,7 +459,7 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
 
                for (i = 0; i < tc->array->len; i++) {
                        struct ctf_trace *tin;
-                       struct trace_descriptor *td_read;
+                       struct bt_trace_descriptor *td_read;
                        int stream_id;
 
                        td_read = g_ptr_array_index(tc->array, i);
@@ -675,7 +683,7 @@ int bt_iter_init(struct bt_iter *iter,
 
        for (i = 0; i < ctx->tc->array->len; i++) {
                struct ctf_trace *tin;
-               struct trace_descriptor *td_read;
+               struct bt_trace_descriptor *td_read;
 
                td_read = g_ptr_array_index(ctx->tc->array, i);
                if (!td_read)
This page took 0.025636 seconds and 4 git commands to generate.