Fix: force the client to create a viewer session before attaching
[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>
26#include <urcu/list.h>
27
28#include <common/hashtable/hashtable.h>
29#include <common/sessiond-comm/sessiond-comm.h>
30
31#include "session.h"
32
33enum connection_type {
34 RELAY_DATA = 1,
35 RELAY_CONTROL = 2,
36 RELAY_VIEWER_COMMAND = 3,
37 RELAY_VIEWER_NOTIFICATION = 4,
38};
39
40/*
41 * Internal structure to map a socket with the corresponding session.
42 * A hashtable indexed on the socket FD is used for the lookups.
43 */
44struct relay_connection {
45 struct lttcomm_sock *sock;
46 struct relay_session *session;
c3b7390b 47 struct relay_viewer_session *viewer_session;
58eb9381
DG
48 struct cds_wfq_node qnode;
49 struct lttng_ht_node_ulong sock_n;
50 struct rcu_head rcu_node;
51 enum connection_type type;
52 /* Protocol version to use for this connection. */
53 uint32_t major;
54 uint32_t minor;
55 uint64_t session_id;
56 struct cds_list_head recv_head;
57 unsigned int version_check_done:1;
58
59 /* Pointer to the sessions HT that this connection can use. */
60 struct lttng_ht *sessions_ht;
61};
62
63struct relay_connection *connection_find_by_sock(struct lttng_ht *ht,
64 int sock);
65struct relay_connection *connection_create(void);
66void connection_init(struct relay_connection *conn);
67void connection_delete(struct lttng_ht *ht, struct relay_connection *conn);
68void connection_destroy(struct relay_connection *conn);
69void connection_free(struct relay_connection *conn);
70
71#endif /* _CONNECTION_H */
This page took 0.026188 seconds and 4 git commands to generate.