Commit | Line | Data |
---|---|---|
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 | ||
13 | #include <limits.h> | |
14 | #include <inttypes.h> | |
15 | #include <pthread.h> | |
16 | #include <urcu/list.h> | |
17 | #include <urcu/ref.h> | |
18 | ||
19 | #include <common/hashtable/hashtable.h> | |
b66a15d1 | 20 | #include <common/trace-chunk.h> |
7591bab1 MD |
21 | |
22 | #include "session.h" | |
23 | ||
24 | struct relay_viewer_session { | |
25 | /* | |
26 | * Session list. Updates are protected by the session_list_lock. | |
27 | * Traversals are protected by RCU. | |
28 | * This list limits the design to having the sessions in at most | |
29 | * one viewer session. | |
30 | */ | |
31 | struct cds_list_head session_list; /* RCU list. */ | |
32 | pthread_mutex_t session_list_lock; /* Protects list updates. */ | |
8aeeba8f JG |
33 | /* |
34 | * The viewer session's current trace chunk is initially set, when | |
35 | * a viewer attaches to the viewer session, to a copy the corresponding | |
36 | * relay_session's current trace chunk. | |
37 | * | |
38 | * A live session always attempts to "catch-up" to the newest available | |
39 | * trace chunk. This means that when a viewer reaches the end of a | |
40 | * trace chunk, the viewer session may not transition to the "next" one: | |
41 | * it jumps to the most recent trace chunk available (the one being | |
42 | * produced by the relay_session). Hence, if the producer performs | |
43 | * multiple rotations before a viewer completes the consumption of a | |
44 | * trace chunk, it will skip over those "intermediary" trace chunks. | |
45 | * | |
46 | * A viewer session updates its current trace chunk when: | |
47 | * 1) new viewer streams are created, | |
48 | * 2) a new index is requested, | |
49 | * 3) metadata is requested. | |
50 | * | |
51 | * Hence, as a general principle, the viewer session will reference the | |
52 | * most recent trace chunk available _even if its streams do not point to | |
53 | * it_. It indicates which trace chunk viewer streams should transition | |
54 | * to when the end of their current trace chunk is reached. | |
55 | */ | |
b66a15d1 | 56 | struct lttng_trace_chunk *current_trace_chunk; |
7591bab1 MD |
57 | }; |
58 | ||
59 | struct relay_viewer_session *viewer_session_create(void); | |
60 | void viewer_session_destroy(struct relay_viewer_session *vsession); | |
61 | void viewer_session_close(struct relay_viewer_session *vsession); | |
62 | ||
dbd6665b JG |
63 | enum lttng_viewer_attach_return_code viewer_session_attach( |
64 | struct relay_viewer_session *vsession, | |
7591bab1 MD |
65 | struct relay_session *session); |
66 | int viewer_session_is_attached(struct relay_viewer_session *vsession, | |
67 | struct relay_session *session); | |
d62023be JD |
68 | void viewer_session_close_one_session(struct relay_viewer_session *vsession, |
69 | struct relay_session *session); | |
b3ab5004 MD |
70 | int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession, |
71 | struct lttng_trace_chunk *relay_session_trace_chunk); | |
7591bab1 MD |
72 | |
73 | #endif /* _VIEWER_SESSION_H */ |