Use compiler-agnostic defines to silence warning
[lttng-tools.git] / src / bin / lttng-relayd / viewer-session.hpp
CommitLineData
7591bab1
MD
1#ifndef _VIEWER_SESSION_H
2#define _VIEWER_SESSION_H
3
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>
7591bab1 8 *
ab5be9fa 9 * SPDX-License-Identifier: GPL-2.0-only
7591bab1 10 *
7591bab1
MD
11 */
12
28f23191
JG
13#include "lttng-viewer-abi.hpp"
14#include "session.hpp"
7591bab1 15
c9e313bc
SM
16#include <common/hashtable/hashtable.hpp>
17#include <common/trace-chunk.hpp>
7591bab1 18
28f23191
JG
19#include <inttypes.h>
20#include <limits.h>
21#include <pthread.h>
22#include <urcu/list.h>
23#include <urcu/ref.h>
7591bab1
MD
24
25struct relay_viewer_session {
98b82dfa
KS
26 /*
27 * The id of the relay viewer session. Uses the associated connection's socket FD.
28 */
29 uint64_t id;
7591bab1
MD
30 /*
31 * Session list. Updates are protected by the session_list_lock.
32 * Traversals are protected by RCU.
33 * This list limits the design to having the sessions in at most
34 * one viewer session.
35 */
28f23191
JG
36 struct cds_list_head session_list; /* RCU list. */
37 pthread_mutex_t session_list_lock; /* Protects list updates. */
98b82dfa
KS
38 /*
39 * Unannounced stream list. Updates are protected by the
40 * unannounced_stream_list_lock. This lock nests inside
41 * the following locks (in order): relay session, ctf_trace,
42 * and relay stream.
43 *
44 * Traversals are protected by RCU.
45 */
46 struct cds_list_head unannounced_stream_list;
47 pthread_mutex_t unannounced_stream_list_lock;
48 /*
49 * Node in the global viewer sessions hashtable.
50 */
51 struct lttng_ht_node_u64 viewer_session_n;
8aeeba8f
JG
52 /*
53 * The viewer session's current trace chunk is initially set, when
54 * a viewer attaches to the viewer session, to a copy the corresponding
55 * relay_session's current trace chunk.
56 *
57 * A live session always attempts to "catch-up" to the newest available
58 * trace chunk. This means that when a viewer reaches the end of a
59 * trace chunk, the viewer session may not transition to the "next" one:
60 * it jumps to the most recent trace chunk available (the one being
61 * produced by the relay_session). Hence, if the producer performs
62 * multiple rotations before a viewer completes the consumption of a
63 * trace chunk, it will skip over those "intermediary" trace chunks.
64 *
65 * A viewer session updates its current trace chunk when:
66 * 1) new viewer streams are created,
67 * 2) a new index is requested,
68 * 3) metadata is requested.
69 *
70 * Hence, as a general principle, the viewer session will reference the
71 * most recent trace chunk available _even if its streams do not point to
72 * it_. It indicates which trace chunk viewer streams should transition
73 * to when the end of their current trace chunk is reached.
d8c6dbdd
JG
74 *
75 * Note that a viewer session's trace chunk points to the session's
76 * output directory. The sub-directories in which the various stream files
77 * are created are considered as being a part of their name.
8aeeba8f 78 */
b66a15d1 79 struct lttng_trace_chunk *current_trace_chunk;
7591bab1
MD
80};
81
0f4aa1a8 82struct relay_viewer_session *viewer_session_create();
7591bab1
MD
83void viewer_session_destroy(struct relay_viewer_session *vsession);
84void viewer_session_close(struct relay_viewer_session *vsession);
85
28f23191
JG
86enum lttng_viewer_attach_return_code viewer_session_attach(struct relay_viewer_session *vsession,
87 struct relay_session *session);
7591bab1 88int viewer_session_is_attached(struct relay_viewer_session *vsession,
28f23191 89 struct relay_session *session);
d62023be 90void viewer_session_close_one_session(struct relay_viewer_session *vsession,
28f23191 91 struct relay_session *session);
b3ab5004 92int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
28f23191 93 struct lttng_trace_chunk *relay_session_trace_chunk);
7591bab1
MD
94
95#endif /* _VIEWER_SESSION_H */
This page took 0.073001 seconds and 4 git commands to generate.