X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fconnection.h;h=98ca9159051652925d1176ff6c00525744e269c8;hp=44386381325e531fb45ea45f233e6f7f3a2ef946;hb=86eff0042bf0b9e6277b281c4f3a680d997790d2;hpb=7591bab11eceedc6a0d1e02fd6f85592267a63b5 diff --git a/src/bin/lttng-relayd/connection.h b/src/bin/lttng-relayd/connection.h index 443863813..98ca91590 100644 --- a/src/bin/lttng-relayd/connection.h +++ b/src/bin/lttng-relayd/connection.h @@ -2,22 +2,12 @@ #define _CONNECTION_H /* - * Copyright (C) 2013 - Julien Desfossez - * David Goulet - * 2015 - Mathieu Desnoyers + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 David Goulet + * Copyright (C) 2015 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -29,6 +19,8 @@ #include #include +#include +#include #include "session.h" @@ -40,6 +32,36 @@ enum connection_type { RELAY_VIEWER_NOTIFICATION = 4, }; +enum data_connection_state { + DATA_CONNECTION_STATE_RECEIVE_HEADER = 0, + DATA_CONNECTION_STATE_RECEIVE_PAYLOAD = 1, +}; + +enum ctrl_connection_state { + CTRL_CONNECTION_STATE_RECEIVE_HEADER = 0, + CTRL_CONNECTION_STATE_RECEIVE_PAYLOAD = 1, +}; + +struct data_connection_state_receive_header { + uint64_t received, left_to_receive; + char header_reception_buffer[sizeof(struct lttcomm_relayd_data_hdr)]; +}; + +struct data_connection_state_receive_payload { + uint64_t received, left_to_receive; + struct lttcomm_relayd_data_hdr header; + bool rotate_index; +}; + +struct ctrl_connection_state_receive_header { + uint64_t received, left_to_receive; +}; + +struct ctrl_connection_state_receive_payload { + uint64_t received, left_to_receive; + struct lttcomm_relayd_hdr header; +}; + /* * Internal structure to map a socket with the corresponding session. * A hashtable indexed on the socket FD is used for the lookups. @@ -77,7 +99,6 @@ struct relay_connection { uint32_t minor; struct urcu_ref ref; - pthread_mutex_t reflock; bool version_check_done; @@ -88,15 +109,36 @@ struct relay_connection { bool in_socket_ht; struct lttng_ht *socket_ht; /* HACK: Contained within this hash table. */ struct rcu_head rcu_node; /* For call_rcu teardown. */ + + union { + struct { + enum data_connection_state state_id; + union { + struct data_connection_state_receive_header receive_header; + struct data_connection_state_receive_payload receive_payload; + } state; + } data; + struct { + enum ctrl_connection_state state_id; + union { + struct ctrl_connection_state_receive_header receive_header; + struct ctrl_connection_state_receive_payload receive_payload; + } state; + struct lttng_dynamic_buffer reception_buffer; + } ctrl; + } protocol; }; struct relay_connection *connection_create(struct lttcomm_sock *sock, enum connection_type type); struct relay_connection *connection_get_by_sock(struct lttng_ht *relay_connections_ht, int sock); +int connection_reset_protocol_state(struct relay_connection *connection); bool connection_get(struct relay_connection *connection); void connection_put(struct relay_connection *connection); void connection_ht_add(struct lttng_ht *relay_connections_ht, struct relay_connection *conn); +int connection_set_session(struct relay_connection *conn, + struct relay_session *session); #endif /* _CONNECTION_H */