c60280e0fd9c717dc0bd0d1e975236ca0e73bed5
[lttng-tools.git] / src / bin / lttng-relayd / lttng-relayd.h
1 /*
2 * Copyright (C) 2012 - 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
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as 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
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #ifndef LTTNG_RELAYD_H
20 #define LTTNG_RELAYD_H
21
22 #define _LGPL_SOURCE
23 #include <urcu.h>
24 #include <urcu/wfqueue.h>
25 #include <common/hashtable/hashtable.h>
26 #include <common/index/lttng-index.h>
27
28 /*
29 * Queue used to enqueue relay requests
30 */
31 struct relay_cmd_queue {
32 struct cds_wfq_queue queue;
33 int32_t futex;
34 };
35
36 enum connection_type {
37 RELAY_DATA,
38 RELAY_CONTROL,
39 };
40
41 /*
42 * Represents a session for the relay point of view
43 */
44 struct relay_session {
45 /*
46 * This session id is used to identify a set of stream to a tracing session
47 * but also make sure we have a unique session id associated with a session
48 * daemon which can provide multiple data source.
49 */
50 uint64_t id;
51 struct lttcomm_sock *sock;
52 };
53
54 /*
55 * Represents a stream in the relay
56 */
57 struct relay_stream {
58 uint64_t stream_handle;
59 uint64_t prev_seq; /* previous data sequence number encountered */
60 struct lttng_ht_node_ulong stream_n;
61 struct relay_session *session;
62 struct rcu_head rcu_node;
63 int fd;
64 /* FD on which to write the index data. */
65 int index_fd;
66
67 char *path_name;
68 char *channel_name;
69 /* on-disk circular buffer of tracefiles */
70 uint64_t tracefile_size;
71 uint64_t tracefile_size_current;
72 uint64_t tracefile_count;
73 uint64_t tracefile_count_current;
74
75 /* Information telling us when to close the stream */
76 unsigned int close_flag:1;
77 uint64_t last_net_seq_num;
78 /* Indicate if the stream was initialized for a data pending command. */
79 unsigned int data_pending_check_done:1;
80 };
81
82 /*
83 * Internal structure to map a socket with the corresponding session.
84 * A hashtable indexed on the socket FD is used for the lookups.
85 */
86 struct relay_command {
87 struct lttcomm_sock *sock;
88 struct relay_session *session;
89 struct cds_wfq_node node;
90 struct lttng_ht_node_ulong sock_n;
91 struct rcu_head rcu_node;
92 enum connection_type type;
93 unsigned int version_check_done:1;
94 /* protocol version to use for this session */
95 uint32_t major;
96 uint32_t minor;
97 };
98
99 extern char *opt_output_path;
100
101 #endif /* LTTNG_RELAYD_H */
This page took 0.032142 seconds and 4 git commands to generate.