relayd: Transmit current trace chunk id in create_sesssion command
[lttng-tools.git] / src / bin / lttng-relayd / session.h
CommitLineData
7591bab1
MD
1#ifndef _SESSION_H
2#define _SESSION_H
3
2f8f53af
DG
4/*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7591bab1 7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2f8f53af
DG
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License, version 2 only, as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
2f8f53af
DG
23#include <limits.h>
24#include <inttypes.h>
25#include <pthread.h>
c3b7390b 26#include <urcu/list.h>
7591bab1 27#include <urcu/ref.h>
2f8f53af 28
36d2e35d 29#include <lttng/constant.h>
2f8f53af 30#include <common/hashtable/hashtable.h>
23c8ff50 31#include <common/compat/uuid.h>
639ddf68 32#include <common/trace-chunk.h>
2f8f53af
DG
33
34/*
35 * Represents a session for the relay point of view
36 */
37struct relay_session {
38 /*
7591bab1
MD
39 * This session id is generated by the relay daemon to guarantee
40 * its uniqueness even when serving multiple session daemons.
41 * It is used to match a set of streams to their session.
2f8f53af
DG
42 */
43 uint64_t id;
23c8ff50 44 lttng_uuid sessiond_uuid;
36d2e35d 45 char session_name[LTTNG_NAME_MAX];
9cf3eb20 46 char hostname[LTTNG_HOST_NAME_MAX];
2f8f53af 47 uint32_t live_timer;
2a174661 48
7591bab1
MD
49 /* Session in snapshot mode. */
50 bool snapshot;
51
52 /*
53 * Session has no back reference to its connection because it
54 * has a life-time that can be longer than the consumer connection's
55 * life-time; a reference can still be held by the viewer
56 * connection through the viewer streams.
57 */
58
59 struct urcu_ref ref;
7591bab1
MD
60
61 pthread_mutex_t lock;
62
63 /* major/minor version used for this session. */
64 uint32_t major;
65 uint32_t minor;
66
67 bool viewer_attached;
68 /* Tell if the session connection has been closed on the streaming side. */
69 bool connection_closed;
2a174661 70
98ba050e
JR
71 /*
72 * Tell if the session is currently living in a exiting relayd and
73 * should be cleaned forcefully without waiting for pending data or
74 * pending ctrl data.
75 */
76 bool aborted;
77
2a174661
DG
78 /* Contains ctf_trace object of that session indexed by path name. */
79 struct lttng_ht *ctf_traces_ht;
2f8f53af
DG
80
81 /*
7591bab1
MD
82 * This contains streams that are received on that connection.
83 * It's used to store them until we get the streams sent
84 * command. When this is received, we remove those streams from
85 * the list and publish them.
86 *
87 * Updates are protected by the recv_list_lock.
88 * Traversals are protected by RCU.
89 * recv_list_lock also protects stream_count.
2f8f53af 90 */
7591bab1
MD
91 struct cds_list_head recv_list; /* RCU list. */
92 uint32_t stream_count;
93 pthread_mutex_t recv_list_lock;
94
2f8f53af
DG
95 /*
96 * Flag checked and exchanged with uatomic_cmpxchg to tell the
97 * viewer-side if new streams got added since the last check.
98 */
99 unsigned long new_streams;
100
101 /*
7591bab1 102 * Node in the global session hash table.
2f8f53af 103 */
7591bab1 104 struct lttng_ht_node_u64 session_n;
c3b7390b
JD
105 /*
106 * Member of the session list in struct relay_viewer_session.
7591bab1
MD
107 * Updates are protected by the relay_viewer_session
108 * session_list_lock. Traversals are protected by RCU.
c3b7390b 109 */
7591bab1 110 struct cds_list_head viewer_session_node;
639ddf68 111 struct lttng_trace_chunk *current_trace_chunk;
7591bab1 112 struct rcu_head rcu_node; /* For call_rcu teardown. */
2f8f53af
DG
113};
114
7591bab1
MD
115struct relay_session *session_create(const char *session_name,
116 const char *hostname, uint32_t live_timer,
23c8ff50
JG
117 bool snapshot, const lttng_uuid sessiond_uuid,
118 uint32_t major, uint32_t minor);
7591bab1
MD
119struct relay_session *session_get_by_id(uint64_t id);
120bool session_get(struct relay_session *session);
121void session_put(struct relay_session *session);
2a174661 122
7591bab1 123int session_close(struct relay_session *session);
98ba050e
JR
124int session_abort(struct relay_session *session);
125
7591bab1 126void print_sessions(void);
2f8f53af
DG
127
128#endif /* _SESSION_H */
This page took 0.041849 seconds and 4 git commands to generate.