2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <urcu/wfqueue.h>
27 #include <urcu/list.h>
29 #include <common/hashtable/hashtable.h>
30 #include <common/sessiond-comm/sessiond-comm.h>
34 enum connection_type
{
37 RELAY_VIEWER_COMMAND
= 3,
38 RELAY_VIEWER_NOTIFICATION
= 4,
42 * Internal structure to map a socket with the corresponding session.
43 * A hashtable indexed on the socket FD is used for the lookups.
45 struct relay_connection
{
46 struct lttcomm_sock
*sock
;
47 struct relay_session
*session
;
48 struct relay_viewer_session
*viewer_session
;
49 struct cds_wfq_node qnode
;
50 struct lttng_ht_node_ulong sock_n
;
51 struct rcu_head rcu_node
;
52 enum connection_type type
;
53 /* Protocol version to use for this connection. */
59 * This contains streams that are received on that connection. It's used to
60 * store them until we get the streams sent command where they are removed
61 * and flagged ready for the viewer. This is ONLY used by the control
62 * thread thus any action on it should happen in that thread.
64 struct cds_list_head recv_head
;
65 unsigned int version_check_done
:1;
67 /* Pointer to the sessions HT that this connection can use. */
68 struct lttng_ht
*sessions_ht
;
71 struct relay_connection
*connection_find_by_sock(struct lttng_ht
*ht
,
73 struct relay_connection
*connection_create(void);
74 void connection_init(struct relay_connection
*conn
);
75 void connection_delete(struct lttng_ht
*ht
, struct relay_connection
*conn
);
76 void connection_destroy(struct relay_connection
*conn
);
77 void connection_free(struct relay_connection
*conn
);
79 #endif /* _CONNECTION_H */