Fix the error path when a trace is opened but errors occur when we index
it, and close all traces when the context is destroyed.
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fprintf(stderr, "[error] [Context] Creating trace handle %s .\n\n",
path);
ret = -1;
fprintf(stderr, "[error] [Context] Creating trace handle %s .\n\n",
path);
ret = -1;
}
handle->format = fmt;
handle->td = td;
}
handle->format = fmt;
handle->td = td;
handle);
ret = trace_collection_add(ctx->tc, td);
if (ret != 0)
handle);
ret = trace_collection_add(ctx->tc, td);
if (ret != 0)
ret = fmt->convert_index_timestamp(td);
if (ret < 0)
ret = fmt->convert_index_timestamp(td);
if (ret < 0)
handle->real_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_REAL);
handle->real_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_REAL);
handle->real_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_REAL);
handle->real_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_REAL);
handle->cycles_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_CYCLES);
return handle->id;
handle->cycles_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_CYCLES);
return handle->id;
+
+error:
+ fmt->close_trace(td);
assert(ctx);
finalize_trace_collection(ctx->tc);
assert(ctx);
finalize_trace_collection(ctx->tc);
- /* Remote all traces. The g_hash_table_destroy will call
+ /*
+ * Remove all traces. The g_hash_table_destroy will call
* bt_trace_handle_destroy on each elements.
*/
g_hash_table_destroy(ctx->trace_handles);
* bt_trace_handle_destroy on each elements.
*/
g_hash_table_destroy(ctx->trace_handles);
void bt_trace_handle_destroy(struct bt_trace_handle *th)
{
void bt_trace_handle_destroy(struct bt_trace_handle *th)
{
+ th->format->close_trace(th->td);