Fix: relayd: live: erroneous message timestamp observed from live viewer
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.cpp
index 7a66fde5bd6b8bf54d540a8aa0762e47ee9017bd..ca0be9a62d200136972ac6922a692a6bb5917526 100644 (file)
@@ -15,6 +15,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <algorithm>
 
 #include "lttng-relayd.h"
 #include "viewer-stream.h"
@@ -302,7 +303,15 @@ void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream
        if (seq_tail == -1ULL) {
                seq_tail = 0;
        }
-       vstream->index_sent_seqcount = seq_tail;
+
+       /*
+        * Move the index sent seqcount forward if it was lagging behind
+        * the new tail of the tracefile array. If the current
+        * index_sent_seqcount is already further than the tracefile
+        * array tail position, keep its current position.
+        */
+       vstream->index_sent_seqcount =
+                       std::max(seq_tail, vstream->index_sent_seqcount);
 }
 
 /*
This page took 0.024204 seconds and 4 git commands to generate.