Fix: use after free of a relayd stream
[lttng-tools.git] / src / bin / lttng-relayd / connection.h
CommitLineData
58eb9381
DG
1/*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 *
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.
8 *
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
12 * more details.
13 *
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.
17 */
18
19#ifndef _CONNECTION_H
20#define _CONNECTION_H
21
22#include <limits.h>
23#include <inttypes.h>
24#include <pthread.h>
25#include <urcu.h>
ed4bd02e 26#include <urcu/wfqueue.h>
58eb9381
DG
27#include <urcu/list.h>
28
29#include <common/hashtable/hashtable.h>
30#include <common/sessiond-comm/sessiond-comm.h>
31
32#include "session.h"
33
34enum connection_type {
35 RELAY_DATA = 1,
36 RELAY_CONTROL = 2,
37 RELAY_VIEWER_COMMAND = 3,
38 RELAY_VIEWER_NOTIFICATION = 4,
39};
40
41/*
42 * Internal structure to map a socket with the corresponding session.
43 * A hashtable indexed on the socket FD is used for the lookups.
44 */
45struct relay_connection {
46 struct lttcomm_sock *sock;
47 struct relay_session *session;
c3b7390b 48 struct relay_viewer_session *viewer_session;
58eb9381
DG
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. */
54 uint32_t major;
55 uint32_t minor;
56 uint64_t session_id;
cd2ef1ef
DG
57
58 /*
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.
63 */
58eb9381
DG
64 struct cds_list_head recv_head;
65 unsigned int version_check_done:1;
66
67 /* Pointer to the sessions HT that this connection can use. */
68 struct lttng_ht *sessions_ht;
69};
70
71struct relay_connection *connection_find_by_sock(struct lttng_ht *ht,
72 int sock);
73struct relay_connection *connection_create(void);
74void connection_init(struct relay_connection *conn);
75void connection_delete(struct lttng_ht *ht, struct relay_connection *conn);
76void connection_destroy(struct relay_connection *conn);
77void connection_free(struct relay_connection *conn);
78
79#endif /* _CONNECTION_H */
This page took 0.025733 seconds and 4 git commands to generate.