+ rcu_read_unlock();
+ return vstream;
+}
+
+void viewer_stream_put(struct relay_viewer_stream *vstream)
+{
+ rcu_read_lock();
+ pthread_mutex_lock(&vstream->reflock);
+ urcu_ref_put(&vstream->ref, viewer_stream_release);
+ pthread_mutex_unlock(&vstream->reflock);
+ rcu_read_unlock();
+}
+
+/*
+ * Returns whether the current tracefile is readable. If not, it has
+ * been overwritten.
+ * Must be called with rstream lock held.
+ */
+bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
+ uint64_t seq)
+{
+ struct relay_stream *stream = vstream->stream;
+
+ if (seq >= stream->oldest_tracefile_seq
+ && seq <= stream->current_tracefile_seq) {
+ /* seq is a readable file. */
+ return true;
+ } else {
+ /* seq is not readable. */
+ return false;
+ }