Fix: bindings import segfaults on missing hash_key_u64
[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#include <common/trace-chunk.h>
33#include <common/optional.h>
34
35/*
36 * Represents a session for the relay point of view
37 */
38struct relay_session {
39 /*
40 * This session id is generated by the relay daemon to guarantee
41 * its uniqueness even when serving multiple session daemons.
42 * It is used to match a set of streams to their session.
43 */
44 uint64_t id;
45 /*
46 * ID of the session in the session daemon's domain.
47 * This information is only provided by 2.11+ peers.
48 */
49 LTTNG_OPTIONAL(uint64_t) id_sessiond;
50 /*
51 * Only provided by 2.11+ peers. However, the UUID is set to 'nil' in
52 * the other cases.
53 */
54 lttng_uuid sessiond_uuid;
55 LTTNG_OPTIONAL(time_t) creation_time;
56 char session_name[LTTNG_NAME_MAX];
57 char hostname[LTTNG_HOST_NAME_MAX];
58 uint32_t live_timer;
59
60 /* Session in snapshot mode. */
61 bool snapshot;
62
63 /*
64 * Session has no back reference to its connection because it
65 * has a life-time that can be longer than the consumer connection's
66 * life-time; a reference can still be held by the viewer
67 * connection through the viewer streams.
68 */
69
70 struct urcu_ref ref;
71
72 pthread_mutex_t lock;
73
74 /* major/minor version used for this session. */
75 uint32_t major;
76 uint32_t minor;
77
78 bool viewer_attached;
79 /* Tell if the session connection has been closed on the streaming side. */
80 bool connection_closed;
81
82 /*
83 * Tell if the session is currently living in a exiting relayd and
84 * should be cleaned forcefully without waiting for pending data or
85 * pending ctrl data.
86 */
87 bool aborted;
88
89 /* Contains ctf_trace object of that session indexed by path name. */
90 struct lttng_ht *ctf_traces_ht;
91
92 /*
93 * This contains streams that are received on that connection.
94 * It's used to store them until we get the streams sent
95 * command. When this is received, we remove those streams from
96 * the list and publish them.
97 *
98 * Updates are protected by the recv_list_lock.
99 * Traversals are protected by RCU.
100 * recv_list_lock also protects stream_count.
101 */
102 struct cds_list_head recv_list; /* RCU list. */
103 uint32_t stream_count;
104 pthread_mutex_t recv_list_lock;
105
106 /*
107 * Flag checked and exchanged with uatomic_cmpxchg to tell the
108 * viewer-side if new streams got added since the last check.
109 */
110 unsigned long new_streams;
111
112 /*
113 * Node in the global session hash table.
114 */
115 struct lttng_ht_node_u64 session_n;
116 /*
117 * Member of the session list in struct relay_viewer_session.
118 * Updates are protected by the relay_viewer_session
119 * session_list_lock. Traversals are protected by RCU.
120 */
121 struct cds_list_head viewer_session_node;
122 struct lttng_trace_chunk *current_trace_chunk;
123 struct lttng_trace_chunk *pending_closure_trace_chunk;
124 struct rcu_head rcu_node; /* For call_rcu teardown. */
125};
126
127struct relay_session *session_create(const char *session_name,
128 const char *hostname,
129 uint32_t live_timer,
130 bool snapshot,
131 const lttng_uuid sessiond_uuid,
132 const uint64_t *id_sessiond,
133 const uint64_t *current_chunk_id,
134 const time_t *creation_time,
135 uint32_t major,
136 uint32_t minor);
137struct relay_session *session_get_by_id(uint64_t id);
138bool session_get(struct relay_session *session);
139void session_put(struct relay_session *session);
140
141int session_close(struct relay_session *session);
142int session_abort(struct relay_session *session);
143
144void print_sessions(void);
145
146#endif /* _SESSION_H */
This page took 0.02238 seconds and 4 git commands to generate.