From: Jérémie Galarneau Date: Wed, 28 Jan 2015 21:52:28 +0000 (-0500) Subject: Fix: lock stream class after assigning stream id X-Git-Tag: v2.0.0-pre1~1425 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=29d9d76c476cbf3fdf6fa709bfbdc24309974f06 Fix: lock stream class after assigning stream id Fixes a bug that was introduced by 2f100782 which made it possible to set custom stream class IDs. The stream class is frozen when a stream of its type is instanciated. However, the trace or writer must still assign a unique ID to the stream class if none were set prior. This modification moves the stream class locking (freeze) after the ID assignment check. Reported-by: Jiri Olsa Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index d291981e..6a71466c 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -296,7 +296,6 @@ struct bt_ctf_stream *bt_ctf_stream_create( stream->id = stream_class->next_stream_id++; stream->stream_class = stream_class; bt_ctf_stream_class_get(stream_class); - bt_ctf_stream_class_freeze(stream_class); stream->events = g_ptr_array_new_with_free_func( (GDestroyNotify) bt_ctf_event_put); if (!stream->events) { diff --git a/formats/ctf/ir/trace.c b/formats/ctf/ir/trace.c index 68bfd67a..59f696eb 100644 --- a/formats/ctf/ir/trace.c +++ b/formats/ctf/ir/trace.c @@ -185,6 +185,7 @@ struct bt_ctf_stream *bt_ctf_trace_create_stream(struct bt_ctf_trace *trace, bt_ctf_stream_get(stream); g_ptr_array_add(trace->streams, stream); + bt_ctf_stream_class_freeze(stream_class); trace->frozen = 1; return stream; diff --git a/include/babeltrace/ctf-ir/stream-internal.h b/include/babeltrace/ctf-ir/stream-internal.h index 4b3250b0..db5eeaf6 100644 --- a/include/babeltrace/ctf-ir/stream-internal.h +++ b/include/babeltrace/ctf-ir/stream-internal.h @@ -53,6 +53,7 @@ struct bt_ctf_stream { struct bt_ctf_field *event_context; }; +/* Stream class should be locked by the caller after creating a stream */ BT_HIDDEN struct bt_ctf_stream *bt_ctf_stream_create( struct bt_ctf_stream_class *stream_class,