ctf: bt_ctf_notif_iter_get_next_notification(): require CC prio. map
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 26 Apr 2017 01:53:25 +0000 (21:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
Since bt_notification_event_create() freezes its clock class priority
map, pass which clock class priority map to use each time you call
bt_ctf_notif_iter_get_next_notification().

In ctf.fs, it's always the same because all the clock classes are known
when the trace object is created.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/common/notif-iter/notif-iter.h
plugins/ctf/fs/data-stream.c
plugins/ctf/fs/fs.h

index f6fe230c6b84a9b3090589d3fa74a0320532f571..bb629b18940bcdc87997ad4af8269b9d16b30db8 100644 (file)
@@ -162,9 +162,6 @@ struct bt_ctf_notif_iter {
                struct bt_ctf_event_class *event_class;
        } meta;
 
-       /* Clock class priority map (owned by this) */
-       struct bt_clock_class_priority_map *cc_prio_map;
-
        /* Current packet (NULL if not created yet) */
        struct bt_ctf_packet *packet;
 
@@ -2193,6 +2190,7 @@ void notify_end_of_packet(struct bt_ctf_notif_iter *notit,
 
 static
 void notify_event(struct bt_ctf_notif_iter *notit,
+               struct bt_clock_class_priority_map *cc_prio_map,
                struct bt_notification **notification)
 {
        struct bt_ctf_event *event;
@@ -2204,7 +2202,7 @@ void notify_event(struct bt_ctf_notif_iter *notit,
                goto end;
        }
 
-       ret = bt_notification_event_create(event, notit->cc_prio_map);
+       ret = bt_notification_event_create(event, cc_prio_map);
        if (!ret) {
                goto end;
        }
@@ -2312,7 +2310,6 @@ end:
 
 BT_HIDDEN
 struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
-               struct bt_clock_class_priority_map *cc_prio_map,
                size_t max_request_sz,
                struct bt_ctf_notif_iter_medium_ops medops,
                void *data, FILE *err_stream)
@@ -2337,7 +2334,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
        };
 
        assert(trace);
-       assert(cc_prio_map);
        assert(medops.request_bytes);
        assert(medops.get_stream);
        notit = g_new0(struct bt_ctf_notif_iter, 1);
@@ -2356,7 +2352,6 @@ struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
                PERR("Failed to initialize stream clock states\n");
                goto error;
        }
-       notit->cc_prio_map = bt_get(cc_prio_map);
        notit->meta.trace = bt_get(trace);
        notit->medium.medops = medops;
        notit->medium.max_request_sz = max_request_sz;
@@ -2400,7 +2395,6 @@ error:
 
 void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit)
 {
-       BT_PUT(notit->cc_prio_map);
        BT_PUT(notit->meta.trace);
        BT_PUT(notit->meta.stream_class);
        BT_PUT(notit->meta.event_class);
@@ -2432,6 +2426,7 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notit)
 
 enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification(
                struct bt_ctf_notif_iter *notit,
+               struct bt_clock_class_priority_map *cc_prio_map,
                struct bt_notification **notification)
 {
        enum bt_ctf_notif_iter_status status = BT_CTF_NOTIF_ITER_STATUS_OK;
@@ -2461,7 +2456,7 @@ enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification(
                        goto end;
                case STATE_EMIT_NOTIF_EVENT:
                        PDBG("Emitting event notification\n");
-                       notify_event(notit, notification);
+                       notify_event(notit, cc_prio_map, notification);
                        if (!*notification) {
                                status = BT_CTF_NOTIF_ITER_STATUS_ERROR;
                        }
index b8b91c5e324ab63578d232123dabac6b6b656524..90a53bae7c841ee9fe439b0328e7011b0556beb6 100644 (file)
@@ -234,8 +234,6 @@ struct bt_ctf_notif_iter_notif_event {
  * incremented.
  *
  * @param trace                        Trace to read
- * @param cc_prio_map          Clock class priority map to use when
- *                             creating the event notifications
  * @param max_request_sz       Maximum buffer size, in bytes, to
  *                             request to
  *                             bt_ctf_notif_iter_medium_ops::request_bytes()
@@ -248,7 +246,6 @@ struct bt_ctf_notif_iter_notif_event {
  */
 BT_HIDDEN
 struct bt_ctf_notif_iter *bt_ctf_notif_iter_create(struct bt_ctf_trace *trace,
-       struct bt_clock_class_priority_map *cc_prio_map,
        size_t max_request_sz, struct bt_ctf_notif_iter_medium_ops medops,
        void *medops_data, FILE *err_stream);
 
@@ -275,6 +272,8 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notif_iter);
  * call this function again, until another status is returned.
  *
  * @param notif_iter           CTF notification iterator
+ * @param cc_prio_map          Clock class priority map to use when
+ *                             creating an event notification
  * @param notification         Returned notification if the function's
  *                             return value is #BT_CTF_NOTIF_ITER_STATUS_OK
  * @returns                    One of #bt_ctf_notif_iter_status values
@@ -282,6 +281,7 @@ void bt_ctf_notif_iter_destroy(struct bt_ctf_notif_iter *notif_iter);
 BT_HIDDEN
 enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_next_notification(
                struct bt_ctf_notif_iter *notit,
+               struct bt_clock_class_priority_map *cc_prio_map,
                struct bt_notification **notification);
 
 #endif /* CTF_NOTIF_ITER_H */
index 70bdf5a8a59adfcb3d6da8968b4247c97620f9dc..38843d7bd2a394c4dcf74a3dffaaf2a89a46b5b6 100644 (file)
@@ -363,6 +363,7 @@ struct ctf_fs_stream *ctf_fs_stream_create(
                goto error;
        }
 
+       stream->cc_prio_map = bt_get(ctf_fs->cc_prio_map);
        g_string_assign(stream->file->path, path);
        ret = ctf_fs_file_open(ctf_fs, stream->file, "rb");
        if (ret) {
@@ -370,7 +371,7 @@ struct ctf_fs_stream *ctf_fs_stream_create(
        }
 
        stream->notif_iter = bt_ctf_notif_iter_create(ctf_fs->metadata->trace,
-                       ctf_fs->cc_prio_map, ctf_fs->page_size, medops, stream,
+                       ctf_fs->page_size, medops, stream,
                        ctf_fs->error_fp);
        if (!stream->notif_iter) {
                goto error;
@@ -397,6 +398,8 @@ void ctf_fs_stream_destroy(struct ctf_fs_stream *stream)
                return;
        }
 
+       bt_put(stream->cc_prio_map);
+
        if (stream->file) {
                ctf_fs_file_destroy(stream->file);
        }
@@ -432,7 +435,7 @@ struct bt_notification_iterator_next_return ctf_fs_stream_next(
        }
 
        notif_iter_status = bt_ctf_notif_iter_get_next_notification(stream->notif_iter,
-                       &ret.notification);
+                       stream->cc_prio_map, &ret.notification);
        if (notif_iter_status != BT_CTF_NOTIF_ITER_STATUS_OK &&
                        notif_iter_status != BT_CTF_NOTIF_ITER_STATUS_EOF) {
                goto translate_status;
index 0e286f1770c8431c75d6bcfec8f812f624cdbe0a..836c106cb98fc80c253be45008e6c7afd4a9e447 100644 (file)
@@ -57,6 +57,7 @@ struct ctf_fs_metadata {
 struct ctf_fs_stream {
        struct ctf_fs_file *file;
        struct bt_ctf_stream *stream;
+       struct bt_clock_class_priority_map *cc_prio_map;
        struct bt_ctf_notif_iter *notif_iter;
        /* A stream is assumed to be indexed. */
        struct index index;
This page took 0.028985 seconds and 4 git commands to generate.