5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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
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.
26 #include <urcu/list.h>
29 #include <lttng/constant.h>
30 #include <common/hashtable/hashtable.h>
33 * Represents a session for the relay point of view
35 struct relay_session
{
37 * This session id is generated by the relay daemon to guarantee
38 * its uniqueness even when serving multiple session daemons.
39 * It is used to match a set of streams to their session.
42 char session_name
[LTTNG_NAME_MAX
];
43 char hostname
[LTTNG_HOST_NAME_MAX
];
46 /* Session in snapshot mode. */
50 * Session has no back reference to its connection because it
51 * has a life-time that can be longer than the consumer connection's
52 * life-time; a reference can still be held by the viewer
53 * connection through the viewer streams.
60 /* major/minor version used for this session. */
65 /* Tell if the session connection has been closed on the streaming side. */
66 bool connection_closed
;
69 * Tell if the session is currently living in a exiting relayd and
70 * should be cleaned forcefully without waiting for pending data or
75 /* Contains ctf_trace object of that session indexed by path name. */
76 struct lttng_ht
*ctf_traces_ht
;
79 * This contains streams that are received on that connection.
80 * It's used to store them until we get the streams sent
81 * command. When this is received, we remove those streams from
82 * the list and publish them.
84 * Updates are protected by the recv_list_lock.
85 * Traversals are protected by RCU.
86 * recv_list_lock also protects stream_count.
88 struct cds_list_head recv_list
; /* RCU list. */
89 uint32_t stream_count
;
90 pthread_mutex_t recv_list_lock
;
93 * Flag checked and exchanged with uatomic_cmpxchg to tell the
94 * viewer-side if new streams got added since the last check.
96 unsigned long new_streams
;
99 * Node in the global session hash table.
101 struct lttng_ht_node_u64 session_n
;
103 * Member of the session list in struct relay_viewer_session.
104 * Updates are protected by the relay_viewer_session
105 * session_list_lock. Traversals are protected by RCU.
107 struct cds_list_head viewer_session_node
;
108 struct rcu_head rcu_node
; /* For call_rcu teardown. */
111 struct relay_session
*session_create(const char *session_name
,
112 const char *hostname
, uint32_t live_timer
,
113 bool snapshot
, uint32_t major
, uint32_t minor
);
114 struct relay_session
*session_get_by_id(uint64_t id
);
115 bool session_get(struct relay_session
*session
);
116 void session_put(struct relay_session
*session
);
118 int session_close(struct relay_session
*session
);
119 int session_abort(struct relay_session
*session
);
121 void print_sessions(void);
123 #endif /* _SESSION_H */