Clean-up: run format-cpp on the tree
[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 {
26 /*
27 * Session list. Updates are protected by the session_list_lock.
28 * Traversals are protected by RCU.
29 * This list limits the design to having the sessions in at most
30 * one viewer session.
31 */
28f23191
JG
32 struct cds_list_head session_list; /* RCU list. */
33 pthread_mutex_t session_list_lock; /* Protects list updates. */
8aeeba8f
JG
34 /*
35 * The viewer session's current trace chunk is initially set, when
36 * a viewer attaches to the viewer session, to a copy the corresponding
37 * relay_session's current trace chunk.
38 *
39 * A live session always attempts to "catch-up" to the newest available
40 * trace chunk. This means that when a viewer reaches the end of a
41 * trace chunk, the viewer session may not transition to the "next" one:
42 * it jumps to the most recent trace chunk available (the one being
43 * produced by the relay_session). Hence, if the producer performs
44 * multiple rotations before a viewer completes the consumption of a
45 * trace chunk, it will skip over those "intermediary" trace chunks.
46 *
47 * A viewer session updates its current trace chunk when:
48 * 1) new viewer streams are created,
49 * 2) a new index is requested,
50 * 3) metadata is requested.
51 *
52 * Hence, as a general principle, the viewer session will reference the
53 * most recent trace chunk available _even if its streams do not point to
54 * it_. It indicates which trace chunk viewer streams should transition
55 * to when the end of their current trace chunk is reached.
d8c6dbdd
JG
56 *
57 * Note that a viewer session's trace chunk points to the session's
58 * output directory. The sub-directories in which the various stream files
59 * are created are considered as being a part of their name.
8aeeba8f 60 */
b66a15d1 61 struct lttng_trace_chunk *current_trace_chunk;
7591bab1
MD
62};
63
64struct relay_viewer_session *viewer_session_create(void);
65void viewer_session_destroy(struct relay_viewer_session *vsession);
66void viewer_session_close(struct relay_viewer_session *vsession);
67
28f23191
JG
68enum lttng_viewer_attach_return_code viewer_session_attach(struct relay_viewer_session *vsession,
69 struct relay_session *session);
7591bab1 70int viewer_session_is_attached(struct relay_viewer_session *vsession,
28f23191 71 struct relay_session *session);
d62023be 72void viewer_session_close_one_session(struct relay_viewer_session *vsession,
28f23191 73 struct relay_session *session);
b3ab5004 74int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession,
28f23191 75 struct lttng_trace_chunk *relay_session_trace_chunk);
7591bab1
MD
76
77#endif /* _VIEWER_SESSION_H */
This page took 0.059191 seconds and 4 git commands to generate.