relayd: create sessiond trace chunk registry on session creation
[lttng-tools.git] / src / bin / lttng-relayd / session.h
... / ...
CommitLineData
1#ifndef _SESSION_H
2#define _SESSION_H
3
4/*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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
23#include <limits.h>
24#include <inttypes.h>
25#include <pthread.h>
26#include <urcu/list.h>
27#include <urcu/ref.h>
28
29#include <lttng/constant.h>
30#include <common/hashtable/hashtable.h>
31#include <common/compat/uuid.h>
32
33/*
34 * Represents a session for the relay point of view
35 */
36struct relay_session {
37 /*
38 * This session id is generated by the relay daemon to guarantee
39 * its uniqueness even when serving multiple session daemons.
40 * It is used to match a set of streams to their session.
41 */
42 uint64_t id;
43 lttng_uuid sessiond_uuid;
44 char session_name[LTTNG_NAME_MAX];
45 char hostname[LTTNG_HOST_NAME_MAX];
46 uint32_t live_timer;
47
48 /* Session in snapshot mode. */
49 bool snapshot;
50
51 /*
52 * Session has no back reference to its connection because it
53 * has a life-time that can be longer than the consumer connection's
54 * life-time; a reference can still be held by the viewer
55 * connection through the viewer streams.
56 */
57
58 struct urcu_ref ref;
59
60 pthread_mutex_t lock;
61
62 /* major/minor version used for this session. */
63 uint32_t major;
64 uint32_t minor;
65
66 bool viewer_attached;
67 /* Tell if the session connection has been closed on the streaming side. */
68 bool connection_closed;
69
70 /*
71 * Tell if the session is currently living in a exiting relayd and
72 * should be cleaned forcefully without waiting for pending data or
73 * pending ctrl data.
74 */
75 bool aborted;
76
77 /* Contains ctf_trace object of that session indexed by path name. */
78 struct lttng_ht *ctf_traces_ht;
79
80 /*
81 * This contains streams that are received on that connection.
82 * It's used to store them until we get the streams sent
83 * command. When this is received, we remove those streams from
84 * the list and publish them.
85 *
86 * Updates are protected by the recv_list_lock.
87 * Traversals are protected by RCU.
88 * recv_list_lock also protects stream_count.
89 */
90 struct cds_list_head recv_list; /* RCU list. */
91 uint32_t stream_count;
92 pthread_mutex_t recv_list_lock;
93
94 /*
95 * Flag checked and exchanged with uatomic_cmpxchg to tell the
96 * viewer-side if new streams got added since the last check.
97 */
98 unsigned long new_streams;
99
100 /*
101 * Node in the global session hash table.
102 */
103 struct lttng_ht_node_u64 session_n;
104 /*
105 * Member of the session list in struct relay_viewer_session.
106 * Updates are protected by the relay_viewer_session
107 * session_list_lock. Traversals are protected by RCU.
108 */
109 struct cds_list_head viewer_session_node;
110 struct rcu_head rcu_node; /* For call_rcu teardown. */
111};
112
113struct relay_session *session_create(const char *session_name,
114 const char *hostname, uint32_t live_timer,
115 bool snapshot, const lttng_uuid sessiond_uuid,
116 uint32_t major, uint32_t minor);
117struct relay_session *session_get_by_id(uint64_t id);
118bool session_get(struct relay_session *session);
119void session_put(struct relay_session *session);
120
121int session_close(struct relay_session *session);
122int session_abort(struct relay_session *session);
123
124void print_sessions(void);
125
126#endif /* _SESSION_H */
This page took 0.022435 seconds and 4 git commands to generate.