Commit | Line | Data |
---|---|---|
2f8f53af DG |
1 | /* |
2 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
3 | * David Goulet <dgoulet@efficios.com> | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License, version 2 only, as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
12 | * more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along with | |
15 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
16 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 | */ | |
18 | ||
19 | #ifndef _VIEWER_STREAM_H | |
20 | #define _VIEWER_STREAM_H | |
21 | ||
22 | #include <limits.h> | |
23 | #include <inttypes.h> | |
24 | #include <pthread.h> | |
25 | ||
26 | #include <common/hashtable/hashtable.h> | |
27 | ||
28 | #include "ctf-trace.h" | |
29 | #include "lttng-viewer-abi.h" | |
30 | ||
31 | /* Stub */ | |
32 | struct relay_stream; | |
33 | ||
34 | /* | |
35 | * Shadow copy of the relay_stream structure for the viewer side. The only | |
36 | * fields updated by the writer (streaming side) after allocation are : | |
37 | * total_index_received and close_flag. Everything else is updated by the | |
38 | * reader (viewer side). | |
39 | */ | |
40 | struct relay_viewer_stream { | |
41 | uint64_t stream_handle; | |
42 | uint64_t session_id; | |
43 | int read_fd; | |
44 | int index_read_fd; | |
45 | char *path_name; | |
46 | char *channel_name; | |
47 | uint64_t last_sent_index; | |
48 | uint64_t total_index_received; | |
49 | uint64_t tracefile_count; | |
50 | uint64_t tracefile_count_current; | |
51 | /* Stop after reading this tracefile. */ | |
52 | uint64_t tracefile_count_last; | |
53 | struct lttng_ht_node_u64 stream_n; | |
54 | struct rcu_head rcu_node; | |
55 | struct ctf_trace *ctf_trace; | |
56 | /* | |
57 | * This lock blocks only when the writer is about to start overwriting | |
58 | * a file currently read by the reader. | |
59 | * | |
60 | * This is nested INSIDE the viewer_stream_rotation_lock. | |
61 | */ | |
62 | pthread_mutex_t overwrite_lock; | |
63 | /* Information telling us if the stream is a metadata stream. */ | |
64 | unsigned int metadata_flag:1; | |
65 | /* | |
66 | * Information telling us that the stream is closed in write, so | |
67 | * we don't expect new indexes and we can read up to EOF. | |
68 | */ | |
69 | unsigned int close_write_flag:1; | |
70 | /* | |
71 | * If the streaming side closes a FD in use in the viewer side, | |
72 | * it sets this flag to inform that it is a normal error. | |
73 | */ | |
74 | unsigned int abort_flag:1; | |
75 | /* Indicates if this stream has been sent to a viewer client. */ | |
76 | unsigned int sent_flag:1; | |
77 | }; | |
78 | ||
79 | struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, | |
80 | enum lttng_viewer_seek seek_t); | |
81 | struct relay_viewer_stream *viewer_stream_find_by_id(uint64_t id); | |
82 | void viewer_stream_destroy(struct relay_viewer_stream *stream); | |
83 | void viewer_stream_delete(struct relay_viewer_stream *stream); | |
84 | int viewer_stream_rotate(struct relay_viewer_stream *vstream, | |
85 | struct relay_stream *stream); | |
86 | ||
87 | #endif /* _VIEWER_STREAM_H */ |