Fix: lib: strengthen clock expectation check for no Unix epoch / no UUID case
[babeltrace.git] / src / lib / graph / iterator.c
index ff9f4a453473e071302a773abe27fb928b8ae072..f882d6c3cf77e9221d6f6af4b4d637d0877b95a6 100644 (file)
 
 #include "component-class.h"
 #include "component.h"
-#include "component-sink.h"
-#include "component-source.h"
 #include "connection.h"
 #include "graph.h"
+#include "iterator.h"
 #include "message-iterator-class.h"
 #include "message/discarded-items.h"
 #include "message/event.h"
-#include "message/iterator.h"
 #include "message/message.h"
 #include "message/message-iterator-inactivity.h"
 #include "message/stream.h"
@@ -120,6 +118,12 @@ void bt_message_iterator_destroy(struct bt_object *obj)
                "%!+i", iterator);
        bt_message_iterator_try_finalize(iterator);
 
+       if (iterator->clock_expectation.type ==
+                       CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID) {
+               BT_CLOCK_CLASS_PUT_REF_AND_RESET(
+                       iterator->clock_expectation.clock_class);
+       }
+
        if (iterator->connection) {
                /*
                 * Remove ourself from the originating connection so
@@ -702,6 +706,8 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator,
                                bt_uuid_copy(iterator->clock_expectation.uuid, clock_class_uuid);
                        } else {
                                iterator->clock_expectation.type = CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID;
+                               iterator->clock_expectation.clock_class = clock_class;
+                               bt_clock_class_get_ref(iterator->clock_expectation.clock_class);
                        }
                        break;
 
@@ -770,26 +776,21 @@ bool clock_classes_are_compatible_one(struct bt_message_iterator *iterator,
                case CLOCK_EXPECTATION_ORIGIN_OTHER_NO_UUID:
                        if (!clock_class) {
                                BT_ASSERT_COND_DEV_MSG(
-                                       "Expecting a clock class, got none.");
+                                       "Expecting clock class %![cc-]+K, got none.",
+                                       iterator->clock_expectation.clock_class);
                                result = false;
                                goto end;
                        }
 
-                       if (bt_clock_class_origin_is_unix_epoch(clock_class)) {
+                       if (clock_class != iterator->clock_expectation.clock_class) {
                                BT_ASSERT_COND_DEV_MSG(
-                                       "Expecting a clock class without Unix epoch origin: %![cc-]+K",
+                                       "Expecting clock class %![cc-]+K, got %![cc-]+K.",
+                                       iterator->clock_expectation.clock_class,
                                        clock_class);
                                result = false;
                                goto end;
                        }
 
-                       if (clock_class_uuid) {
-                               BT_ASSERT_COND_DEV_MSG(
-                                       "Expecting a clock class without UUID: %![cc-]+K",
-                                       clock_class);
-                               result = false;
-                               goto end;
-                       }
                        break;
                }
        }
@@ -1257,7 +1258,7 @@ bt_message_iterator_next(
         * by its downstream owner.
         *
         * For the same reason, there is no way that this iterator could
-        * have seeked (cannot seek a self message iterator).
+        * have sought (cannot seek a self message iterator).
         */
        BT_ASSERT_DBG(iterator->state ==
                BT_MESSAGE_ITERATOR_STATE_ACTIVE);
@@ -2028,7 +2029,7 @@ end:
 
 /*
  * This function is installed as the iterator's next callback after we have
- * auto-seeked (seeked to the beginning and fast-forwarded) to send the
+ * auto-sought (sought to the beginning and fast-forwarded) to send the
  * messages saved in iterator->auto_seek.msgs.  Once this is done, the original
  * next callback is put back.
  */
This page took 0.025701 seconds and 4 git commands to generate.