Backport: relayd: replace lttng_index_file with relay_index_file
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.h
1 #ifndef _VIEWER_STREAM_H
2 #define _VIEWER_STREAM_H
3
4 /*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License, version 2 only, as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23 #include <limits.h>
24 #include <inttypes.h>
25 #include <pthread.h>
26
27 #include <common/hashtable/hashtable.h>
28
29 #include "ctf-trace.h"
30 #include "lttng-viewer-abi.h"
31 #include "stream.h"
32 #include "index-file.h"
33
34 struct relay_stream;
35
36 /*
37 * The viewer stream's lifetime is the intersection of their viewer connection's
38 * lifetime and the duration during which at least:
39 * a) their input source is still active
40 * b) they still have data left to send to the client.
41 *
42 * This means that both the sessiond/consumerd connection or the viewer
43 * connection may tear down (and unpublish) a relay_viewer_stream.
44 *
45 * Viewer stream updates are protected by their associated stream's lock.
46 */
47 struct relay_viewer_stream {
48 struct urcu_ref ref;
49 pthread_mutex_t reflock;
50
51 /* Back ref to stream. */
52 struct relay_stream *stream;
53
54 /* FD from which to read the stream data. */
55 struct stream_fd *stream_fd;
56 /* index file from which to read the index data. */
57 struct relay_index_file *index_file;
58
59 char *path_name;
60 char *channel_name;
61
62 uint64_t current_tracefile_id;
63
64 /*
65 * Counts the number of sent indexes. The "tag" associated
66 * with an index to send is the current index_received_seqcount,
67 * because we increment index_received_seqcount after sending
68 * each index. This index_received_seqcount counter can also be
69 * updated when catching up with the producer.
70 */
71 uint64_t index_sent_seqcount;
72
73 /* Indicates if this stream has been sent to a viewer client. */
74 bool sent_flag;
75 /* For metadata stream, how much metadata has been sent. */
76 uint64_t metadata_sent;
77
78 struct lttng_ht_node_u64 stream_n;
79 struct rcu_head rcu_node;
80 };
81
82 struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
83 enum lttng_viewer_seek seek_t);
84
85 struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
86 bool viewer_stream_get(struct relay_viewer_stream *vstream);
87 void viewer_stream_put(struct relay_viewer_stream *vstream);
88 int viewer_stream_rotate(struct relay_viewer_stream *vstream);
89 bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
90 uint64_t seq);
91 void print_viewer_streams(void);
92
93 #endif /* _VIEWER_STREAM_H */
This page took 0.035147 seconds and 5 git commands to generate.