Commit | Line | Data |
---|---|---|
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 | ||
2f8f53af DG |
13 | #include <limits.h> |
14 | #include <inttypes.h> | |
15 | #include <pthread.h> | |
16 | ||
17 | #include <common/hashtable/hashtable.h> | |
18 | ||
19 | #include "ctf-trace.h" | |
20 | #include "lttng-viewer-abi.h" | |
2a174661 | 21 | #include "stream.h" |
2f8f53af | 22 | |
2f8f53af DG |
23 | struct 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 | */ |
36 | struct relay_viewer_stream { | |
7591bab1 | 37 | struct urcu_ref ref; |
7591bab1 MD |
38 | |
39 | /* Back ref to stream. */ | |
40 | struct relay_stream *stream; | |
41 | ||
ebb29c10 | 42 | struct { |
8bb66c3c | 43 | struct fs_handle *handle; |
ebb29c10 JG |
44 | struct lttng_trace_chunk *trace_chunk; |
45 | } stream_file; | |
f8f3885c MD |
46 | /* index file from which to read the index data. */ |
47 | struct lttng_index_file *index_file; | |
7591bab1 | 48 | |
2f8f53af DG |
49 | char *path_name; |
50 | char *channel_name; | |
7591bab1 MD |
51 | |
52 | uint64_t current_tracefile_id; | |
7591bab1 | 53 | |
a44ca2ca MD |
54 | /* |
55 | * Counts the number of sent indexes. The "tag" associated | |
56 | * with an index to send is the current index_received_seqcount, | |
57 | * because we increment index_received_seqcount after sending | |
58 | * each index. This index_received_seqcount counter can also be | |
59 | * updated when catching up with the producer. | |
60 | */ | |
61 | uint64_t index_sent_seqcount; | |
7591bab1 MD |
62 | |
63 | /* Indicates if this stream has been sent to a viewer client. */ | |
64 | bool sent_flag; | |
65 | /* For metadata stream, how much metadata has been sent. */ | |
66 | uint64_t metadata_sent; | |
67 | ||
2f8f53af DG |
68 | struct lttng_ht_node_u64 stream_n; |
69 | struct rcu_head rcu_node; | |
2f8f53af DG |
70 | }; |
71 | ||
72 | struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, | |
b66a15d1 | 73 | struct lttng_trace_chunk *viewer_trace_chunk, |
7591bab1 MD |
74 | enum lttng_viewer_seek seek_t); |
75 | ||
76 | struct relay_viewer_stream *viewer_stream_get_by_id(uint64_t id); | |
77 | bool viewer_stream_get(struct relay_viewer_stream *vstream); | |
78 | void viewer_stream_put(struct relay_viewer_stream *vstream); | |
79 | int viewer_stream_rotate(struct relay_viewer_stream *vstream); | |
80 | bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream, | |
81 | uint64_t seq); | |
82 | void print_viewer_streams(void); | |
3087b021 MD |
83 | void viewer_stream_close_files(struct relay_viewer_stream *vstream); |
84 | void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream); | |
2f8f53af DG |
85 | |
86 | #endif /* _VIEWER_STREAM_H */ |