bt_notification_event_create(): validate and freeze event
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 4 Apr 2017 00:23:17 +0000 (20:23 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:40 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/event-internal.h
lib/component/notification/event.c

index 85fea18cd4817c5ae70127e0fe8cf4ef2ae0b43d..c47e61f047066b25672ae983212e25179fe4dba6 100644 (file)
@@ -64,6 +64,14 @@ int bt_ctf_event_serialize(struct bt_ctf_event *event,
 BT_HIDDEN
 void bt_ctf_event_freeze(struct bt_ctf_event *event);
 
+BT_HIDDEN
+static inline struct bt_ctf_packet *bt_ctf_event_borrow_packet(
+               struct bt_ctf_event *event)
+{
+       assert(event);
+       return event->packet;
+}
+
 static inline
 struct bt_ctf_event_class *bt_ctf_event_borrow_event_class(
                struct bt_ctf_event *event)
index c3c461a1e86fafc9da1f057223b86e9cd1d1333b..bae1912fe2b0b885cf3d62e82bc0e8f9104fb144 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <babeltrace/compiler.h>
 #include <babeltrace/ctf-ir/event.h>
+#include <babeltrace/ctf-ir/event-internal.h>
 #include <babeltrace/ctf-ir/event-class.h>
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/ctf-ir/trace.h>
@@ -94,14 +95,16 @@ end:
 struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
                struct bt_clock_class_priority_map *cc_prio_map)
 {
-       struct bt_notification_event *notification;
+       struct bt_notification_event *notification = NULL;
 
        if (!event || !cc_prio_map) {
                goto error;
        }
 
-       // FIXME - Validate that the event is associated to a packet
-       //         and freeze the event.
+       if (!bt_ctf_event_borrow_packet(event)) {
+               goto error;
+       }
+
        notification = g_new0(struct bt_notification_event, 1);
        if (!notification) {
                goto error;
@@ -111,14 +114,14 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event,
                        bt_notification_event_destroy);
        notification->event = bt_get(event);
        notification->cc_prio_map = bt_get(cc_prio_map);
-
        if (!validate_clock_classes(notification)) {
-               bt_put(notification);
                goto error;
        }
 
+       bt_ctf_event_freeze(notification->event);
        return &notification->parent;
 error:
+       bt_put(notification);
        return NULL;
 }
 
This page took 0.030104 seconds and 4 git commands to generate.