2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
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.
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
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.
19 #ifndef _VIEWER_STREAM_H
20 #define _VIEWER_STREAM_H
26 #include <common/hashtable/hashtable.h>
28 #include "ctf-trace.h"
29 #include "lttng-viewer-abi.h"
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).
40 struct relay_viewer_stream
{
41 uint64_t stream_handle
;
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
;
57 * This lock blocks only when the writer is about to start overwriting
58 * a file currently read by the reader.
60 * This is nested INSIDE the viewer_stream_rotation_lock.
62 pthread_mutex_t overwrite_lock
;
63 /* Information telling us if the stream is a metadata stream. */
64 unsigned int metadata_flag
:1;
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.
69 unsigned int close_write_flag
:1;
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.
74 unsigned int abort_flag
:1;
75 /* Indicates if this stream has been sent to a viewer client. */
76 unsigned int sent_flag
:1;
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
);
87 #endif /* _VIEWER_STREAM_H */