Fix: sessiond: leak of application socket on chmod failure
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.h
CommitLineData
7591bab1
MD
1#ifndef _VIEWER_STREAM_H
2#define _VIEWER_STREAM_H
3
2f8f53af
DG
4/*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7591bab1 7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2f8f53af
DG
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
2f8f53af
DG
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"
2a174661 31#include "stream.h"
2f8f53af 32
2f8f53af
DG
33struct relay_stream;
34
35/*
7591bab1
MD
36 * The viewer stream's lifetime is the intersection of their viewer connection's
37 * lifetime and the duration during which at least:
38 * a) their input source is still active
39 * b) they still have data left to send to the client.
40 *
41 * This means that both the sessiond/consumerd connection or the viewer
42 * connection may tear down (and unpublish) a relay_viewer_stream.
43 *
44 * Viewer stream updates are protected by their associated stream's lock.
2f8f53af
DG
45 */
46struct relay_viewer_stream {
7591bab1 47 struct urcu_ref ref;
7591bab1
MD
48
49 /* Back ref to stream. */
50 struct relay_stream *stream;
51
ebb29c10
JG
52 struct {
53 /* FD from which to read the stream data. */
54 struct stream_fd *fd;
55 struct lttng_trace_chunk *trace_chunk;
56 } stream_file;
f8f3885c
MD
57 /* index file from which to read the index data. */
58 struct lttng_index_file *index_file;
7591bab1 59
2f8f53af
DG
60 char *path_name;
61 char *channel_name;
7591bab1
MD
62
63 uint64_t current_tracefile_id;
7591bab1 64
a44ca2ca
MD
65 /*
66 * Counts the number of sent indexes. The "tag" associated
67 * with an index to send is the current index_received_seqcount,
68 * because we increment index_received_seqcount after sending
69 * each index. This index_received_seqcount counter can also be
70 * updated when catching up with the producer.
71 */
72 uint64_t index_sent_seqcount;
7591bab1
MD
73
74 /* Indicates if this stream has been sent to a viewer client. */
75 bool sent_flag;
76 /* For metadata stream, how much metadata has been sent. */
77 uint64_t metadata_sent;
78
2f8f53af
DG
79 struct lttng_ht_node_u64 stream_n;
80 struct rcu_head rcu_node;
2f8f53af
DG
81};
82
83struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
b66a15d1 84 struct lttng_trace_chunk *viewer_trace_chunk,
7591bab1
MD
85 enum lttng_viewer_seek seek_t);
86
87struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id);
88bool viewer_stream_get(struct relay_viewer_stream *vstream);
89void viewer_stream_put(struct relay_viewer_stream *vstream);
90int viewer_stream_rotate(struct relay_viewer_stream *vstream);
91bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
92 uint64_t seq);
93void print_viewer_streams(void);
2f8f53af
DG
94
95#endif /* _VIEWER_STREAM_H */
This page took 0.057307 seconds and 4 git commands to generate.