| 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 <limits.h> |
| 24 | #include <urcu.h> |
| 25 | #include <urcu/wfqueue.h> |
| 26 | #include <urcu/list.h> |
| 27 | |
| 28 | #include <common/hashtable/hashtable.h> |
| 29 | #include <common/index/ctf-index.h> |
| 30 | |
| 31 | #include "ctf-trace.h" |
| 32 | #include "session.h" |
| 33 | |
| 34 | /* |
| 35 | * Queue used to enqueue relay requests |
| 36 | */ |
| 37 | struct relay_cmd_queue { |
| 38 | struct cds_wfq_queue queue; |
| 39 | int32_t futex; |
| 40 | }; |
| 41 | |
| 42 | enum connection_type { |
| 43 | RELAY_DATA = 1, |
| 44 | RELAY_CONTROL = 2, |
| 45 | RELAY_VIEWER_COMMAND = 3, |
| 46 | RELAY_VIEWER_NOTIFICATION = 4, |
| 47 | }; |
| 48 | |
| 49 | /* |
| 50 | * Internal structure to map a socket with the corresponding session. |
| 51 | * A hashtable indexed on the socket FD is used for the lookups. |
| 52 | */ |
| 53 | struct relay_command { |
| 54 | struct lttcomm_sock *sock; |
| 55 | struct relay_session *session; |
| 56 | struct cds_wfq_node node; |
| 57 | struct lttng_ht_node_ulong sock_n; |
| 58 | struct rcu_head rcu_node; |
| 59 | enum connection_type type; |
| 60 | /* protocol version to use for this session */ |
| 61 | uint32_t major; |
| 62 | uint32_t minor; |
| 63 | uint64_t session_id; |
| 64 | struct cds_list_head recv_head; |
| 65 | unsigned int version_check_done:1; |
| 66 | }; |
| 67 | |
| 68 | struct relay_local_data { |
| 69 | struct lttng_ht *sessions_ht; |
| 70 | }; |
| 71 | |
| 72 | extern char *opt_output_path; |
| 73 | |
| 74 | /* |
| 75 | * Contains stream indexed by ID. This is important since many commands lookup |
| 76 | * streams only by ID thus also keeping them in this hash table makes the |
| 77 | * search O(1) instead of iterating over the ctf_traces_ht of the session. |
| 78 | */ |
| 79 | extern struct lttng_ht *relay_streams_ht; |
| 80 | |
| 81 | extern struct lttng_ht *viewer_streams_ht; |
| 82 | extern struct lttng_ht *indexes_ht; |
| 83 | |
| 84 | extern const char *tracing_group_name; |
| 85 | |
| 86 | extern const char * const config_section_name; |
| 87 | |
| 88 | void lttng_relay_notify_ready(void); |
| 89 | |
| 90 | #endif /* LTTNG_RELAYD_H */ |