From: Philippe Proulx Date: Wed, 26 Apr 2017 00:40:59 +0000 (-0400) Subject: Freeze bt_clock_class_priority_map in related notifications X-Git-Tag: v2.0.0-pre1~351 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=fe650ea463f79d205d446a6f62b2e0016dbdf52e;p=babeltrace.git Freeze bt_clock_class_priority_map in related notifications We don't want the relative priorities of a notification's clock classes (event, inactivity) to change once it's emitted. Should a new clock class be needed (with its own priority), you should create a new clock class priority map. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/include/babeltrace/graph/clock-class-priority-map-internal.h b/include/babeltrace/graph/clock-class-priority-map-internal.h index 57c6c86a..3cba2bb9 100644 --- a/include/babeltrace/graph/clock-class-priority-map-internal.h +++ b/include/babeltrace/graph/clock-class-priority-map-internal.h @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -43,6 +45,16 @@ struct bt_clock_class_priority_map { /* Clock class (weak) with the currently highest priority */ struct bt_ctf_clock_class *highest_prio_cc; + + bool frozen; }; +static inline +void bt_clock_class_priority_map_freeze( + struct bt_clock_class_priority_map *cc_prio_map) +{ + assert(cc_prio_map); + cc_prio_map->frozen = true; +} + #endif /* BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H */ diff --git a/include/babeltrace/graph/clock-class-priority-map.h b/include/babeltrace/graph/clock-class-priority-map.h index 18c27308..575e31c1 100644 --- a/include/babeltrace/graph/clock-class-priority-map.h +++ b/include/babeltrace/graph/clock-class-priority-map.h @@ -56,6 +56,16 @@ A priority is a 64-bit unsigned integer. A lower value has a \em higher priority. Multiple clock classes can have the same priority within a given clock class priority map. +The following functions can \em freeze clock class priority map objects: + +- bt_notification_event_create() freezes its clock class priority + map parameter. +- bt_notification_inactivity_create() freezes its clock class priority + map parameter. + +You cannot modify a frozen clock class priority map object: it is +considered immutable, except for \link refs reference counting\endlink. + As with any Babeltrace object, clock class priority map objects have reference counts. See \ref refs to learn more about the reference counting @@ -256,6 +266,7 @@ map. @prenotnull{clock_class_priority_map} @prenotnull{clock_class} +@prehot{clock_class_priority_map} @postrefcountsame{clock_class_priority_map} @postsuccessrefcountinc{clock_class} diff --git a/lib/graph/clock-class-priority-map.c b/lib/graph/clock-class-priority-map.c index f9055198..136ed276 100644 --- a/lib/graph/clock-class-priority-map.c +++ b/lib/graph/clock-class-priority-map.c @@ -229,7 +229,7 @@ int bt_clock_class_priority_map_add_clock_class( // FIXME when available: check // bt_ctf_clock_class_is_valid(clock_class) - if (!cc_prio_map) { + if (!cc_prio_map || !clock_class || cc_prio_map->frozen) { ret = -1; goto end; } diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index 6a1903dc..44bb6f23 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -31,6 +31,7 @@ #include #include #include +#include #include static @@ -144,6 +145,7 @@ struct bt_notification *bt_notification_event_create(struct bt_ctf_event *event, } bt_ctf_event_freeze(notification->event); + bt_clock_class_priority_map_freeze(notification->cc_prio_map); return ¬ification->parent; error: bt_put(notification); diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c index 48073955..27b6916f 100644 --- a/lib/graph/notification/inactivity.c +++ b/lib/graph/notification/inactivity.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -67,6 +68,7 @@ struct bt_notification *bt_notification_inactivity_create( } notification->cc_prio_map = bt_get(cc_prio_map); + bt_clock_class_priority_map_freeze(cc_prio_map); goto end; error: