Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.hpp
CommitLineData
7591bab1
MD
1#ifndef _VIEWER_STREAM_H
2#define _VIEWER_STREAM_H
3
2f8f53af 4/*
ab5be9fa
MJ
5 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
6 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
7 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2f8f53af 8 *
ab5be9fa 9 * SPDX-License-Identifier: GPL-2.0-only
2f8f53af 10 *
2f8f53af
DG
11 */
12
c9e313bc
SM
13#include "ctf-trace.hpp"
14#include "lttng-viewer-abi.hpp"
15#include "stream.hpp"
2f8f53af 16
28f23191
JG
17#include <common/hashtable/hashtable.hpp>
18
19#include <inttypes.h>
20#include <limits.h>
21#include <pthread.h>
22
2f8f53af
DG
23struct relay_stream;
24
25/*
7591bab1
MD
26 * The viewer stream's lifetime is the intersection of their viewer connection's
27 * lifetime and the duration during which at least:
28 * a) their input source is still active
29 * b) they still have data left to send to the client.
30 *
31 * This means that both the sessiond/consumerd connection or the viewer
32 * connection may tear down (and unpublish) a relay_viewer_stream.
33 *
34 * Viewer stream updates are protected by their associated stream's lock.
2f8f53af
DG
35 */
36struct relay_viewer_stream {
7591bab1 37 struct urcu_ref ref;
7591bab1
MD
38
39 /* Back ref to stream. */
40 struct relay_stream *stream;
41
98b82dfa
KS
42 /*
43 * Member of unannounced_stream_list in struct viewer_sesion.
44 * Updates are protected by the unannounced_stream_list_lock, and
45 * traversals are protected by RCU.
46 */
47 struct cds_list_head viewer_stream_node;
48
ebb29c10 49 struct {
8bb66c3c 50 struct fs_handle *handle;
ebb29c10
JG
51 struct lttng_trace_chunk *trace_chunk;
52 } stream_file;
f8f3885c
MD
53 /* index file from which to read the index data. */
54 struct lttng_index_file *index_file;
80516611
JG
55 /*
56 * Last seen rotation count in stream.
57 *
58 * Sampled on every change to the viewer stream trace chunk,
59 * this allows the live server to determine if it saw the latest
60 * rotation that occurred on the receiving end.
61 */
62 uint64_t last_seen_rotation_count;
7591bab1 63
2f8f53af
DG
64 char *path_name;
65 char *channel_name;
7591bab1
MD
66
67 uint64_t current_tracefile_id;
7591bab1 68
a44ca2ca
MD
69 /*
70 * Counts the number of sent indexes. The "tag" associated
71 * with an index to send is the current index_received_seqcount,
72 * because we increment index_received_seqcount after sending
73 * each index. This index_received_seqcount counter can also be
74 * updated when catching up with the producer.
75 */
76 uint64_t index_sent_seqcount;
7591bab1
MD
77
78 /* Indicates if this stream has been sent to a viewer client. */
79 bool sent_flag;
80 /* For metadata stream, how much metadata has been sent. */
81 uint64_t metadata_sent;
82
2f8f53af
DG
83 struct lttng_ht_node_u64 stream_n;
84 struct rcu_head rcu_node;
2f8f53af
DG
85};
86
87struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
28f23191
JG
88 struct lttng_trace_chunk *viewer_trace_chunk,
89 enum lttng_viewer_seek seek_t);
7591bab1
MD
90
91struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
92bool viewer_stream_get(struct relay_viewer_stream *vstream);
93void viewer_stream_put(struct relay_viewer_stream *vstream);
94int viewer_stream_rotate(struct relay_viewer_stream *vstream);
28f23191 95bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream, uint64_t seq);
0f4aa1a8 96void print_viewer_streams();
3087b021
MD
97void viewer_stream_close_files(struct relay_viewer_stream *vstream);
98void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
2f8f53af
DG
99
100#endif /* _VIEWER_STREAM_H */
This page took 0.07794 seconds and 4 git commands to generate.