const LttvTracefileContext *trace_b = (const LttvTracefileContext *)b;
if(likely(trace_a != trace_b)) {
- comparison = ltt_time_compare(trace_b->timestamp, trace_a->timestamp);
+ comparison = ltt_time_compare(trace_a->timestamp, trace_b->timestamp);
if(unlikely(comparison == 0)) {
if(trace_a->index < trace_b->index) comparison = -1;
else if(trace_a->index > trace_b->index) comparison = 1;
self->traces = g_new(LttvTraceContext *, nb_trace);
self->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
self->ts_a = lttv_traceset_attribute(ts);
- self->sync_position = lttv_traceset_context_position_new();
+ // self->sync_position = lttv_traceset_context_position_new();
for(i = 0 ; i < nb_trace ; i++) {
tc = LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_trace_context(self);
self->traces[i] = tc;
g_tree_destroy(self->pqueue);
g_object_unref(self->a);
- lttv_traceset_context_position_destroy(self->sync_position);
+ // lttv_traceset_context_position_destroy(self->sync_position);
nb_trace = lttv_traceset_number(ts);
}
+enum read_state { LAST_NONE, LAST_OK, LAST_EMPTY };
+
/* Note : a _middle must be preceded from a _seek or another middle */
guint lttv_process_traceset_middle(LttvTracesetContext *self,
LttTime end,
unsigned count = 0;
- guint read_ret = FALSE;
+ guint read_ret;
+
+ enum read_state last_read_state = LAST_NONE;
gboolean last_ret = FALSE; /* return value of the last hook list called */
{
return count;
}
-
+
/* Get the tracefile with an event for the smallest time found. If two
or more tracefiles have events for the same time, hope that lookup
and remove are consistent. */
g_tree_foreach(pqueue, test_tree, tfc);
#endif //DEBUG
- count++;
-
e = ltt_tracefile_get_event(tfc->tf);
- fac_id = ltt_event_facility_id(e);
- ev_id = ltt_event_eventtype_id(e);
- id = GET_HOOK_ID(fac_id, ev_id);
- last_ret = lttv_hooks_call_merge(tfc->event, tfc,
- lttv_hooks_by_id_get(tfc->event_by_id, id), tfc);
+ if(last_read_state != LAST_EMPTY) {
+ /* Only call hooks if the last read has given an event or if we are at the
+ * first pass (not if last read returned end of tracefile) */
+ count++;
+
+ fac_id = ltt_event_facility_id(e);
+ ev_id = ltt_event_eventtype_id(e);
+ id = GET_HOOK_ID(fac_id, ev_id);
+ last_ret = lttv_hooks_call_merge(tfc->event, tfc,
+ lttv_hooks_by_id_get(tfc->event_by_id, id), tfc);
+ }
+
read_ret = ltt_tracefile_read(tfc->tf);
if(likely(!read_ret)) {
tfc->timestamp = ltt_event_time(e);
g_tree_insert(pqueue, tfc, tfc);
+ last_read_state = LAST_OK;
} else {
tfc->timestamp = ltt_time_infinite;
- if(read_ret == ERANGE)
+ if(read_ret == ERANGE) {
+ last_read_state = LAST_EMPTY;
g_debug("End of trace");
- else
+ } else
g_error("Error happened in lttv_process_traceset_middle");
}
}
return tfc;
}
-
+#if 0
/* lttv_process_traceset_synchronize_tracefiles
*
* Use the sync_position field of the trace set context to synchronize each
lttv_traceset_context_position_save(tsc, tsc->sync_position);
}
-
+#endif //0