| 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 | |
| 26 | /* |
| 27 | * Queue used to enqueue relay requests |
| 28 | */ |
| 29 | struct relay_cmd_queue { |
| 30 | struct cds_wfq_queue queue; |
| 31 | int32_t futex; |
| 32 | }; |
| 33 | |
| 34 | enum connection_type { |
| 35 | RELAY_DATA, |
| 36 | RELAY_CONTROL, |
| 37 | }; |
| 38 | |
| 39 | /* |
| 40 | * Represents a session for the relay point of view |
| 41 | */ |
| 42 | struct relay_session { |
| 43 | uint64_t id; |
| 44 | struct lttcomm_sock *sock; |
| 45 | }; |
| 46 | |
| 47 | /* |
| 48 | * Represents a stream in the relay |
| 49 | */ |
| 50 | struct relay_stream { |
| 51 | uint64_t stream_handle; |
| 52 | uint64_t prev_seq; /* previous data sequence number encountered */ |
| 53 | struct lttng_ht_node_ulong stream_n; |
| 54 | struct relay_session *session; |
| 55 | struct rcu_head rcu_node; |
| 56 | int fd; |
| 57 | |
| 58 | /* Information telling us when to close the stream */ |
| 59 | unsigned int close_flag:1; |
| 60 | uint64_t last_net_seq_num; |
| 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * Internal structure to map a socket with the corresponding session. |
| 65 | * A hashtable indexed on the socket FD is used for the lookups. |
| 66 | */ |
| 67 | struct relay_command { |
| 68 | struct lttcomm_sock *sock; |
| 69 | struct relay_session *session; |
| 70 | struct cds_wfq_node node; |
| 71 | struct lttng_ht_node_ulong sock_n; |
| 72 | struct rcu_head rcu_node; |
| 73 | enum connection_type type; |
| 74 | unsigned int version_check_done:1; |
| 75 | }; |
| 76 | |
| 77 | #endif /* LTTNG_RELAYD_H */ |