Fix: lock stream class after assigning stream id
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Jan 2015 21:52:28 +0000 (16:52 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 28 Jan 2015 21:52:28 +0000 (16:52 -0500)
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 <jolsa@redhat.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/stream.c
formats/ctf/ir/trace.c
include/babeltrace/ctf-ir/stream-internal.h

index d291981eaace2fe1eb9fd16070755b5ee3d2fcac..6a71466ca3a60022a178b684b43508e4bed6a5be 100644 (file)
@@ -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) {
index 68bfd67afdab8e71ad38189ac104c397a2a5c98e..59f696ebc9eab6280801de9e15c65292e00fd7cf 100644 (file)
@@ -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;
 
index 4b3250b0f89ac074d1ba18d6070885d272aa5690..db5eeaf6896bcffaa67cf5d0425dfdaad83bf961 100644 (file)
@@ -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,
This page took 0.026072 seconds and 4 git commands to generate.