REORG: listener: move xfer_sock_list to sock.{c,h}.

This will be used for receivers as well thus it is not specific to
listeners but to sockets.
This commit is contained in:
Willy Tarreau 2020-08-28 16:29:53 +02:00
parent e5bdc51bb5
commit 063d47d136
7 changed files with 55 additions and 15 deletions

View File

@ -265,17 +265,6 @@ struct bind_kw_list {
struct bind_kw kw[VAR_ARRAY];
};
struct xfer_sock_list {
int fd;
char *iface;
char *namespace;
int options; /* socket options LI_O_* */
struct xfer_sock_list *prev;
struct xfer_sock_list *next;
struct sockaddr_storage addr;
};
/* This is used to create the accept queue, optimized to be 64 bytes long. */
struct accept_queue_entry {
struct listener *listener; // 8 bytes

View File

@ -184,8 +184,6 @@ static inline const char *listener_state_str(const struct listener *l)
return states[st];
}
extern struct xfer_sock_list *xfer_sock_list;
extern struct accept_queue_ring accept_queue_rings[MAX_THREADS] __attribute__((aligned(64)));
#endif /* _HAPROXY_LISTENER_H */

48
include/haproxy/sock-t.h Normal file
View File

@ -0,0 +1,48 @@
/*
* include/haproxy/sock-t.h
* This file contains type definitions for native (BSD-compatible) sockets.
*
* Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _HAPROXY_SOCK_T_H
#define _HAPROXY_SOCK_T_H
#include <sys/socket.h>
#include <sys/types.h>
#include <haproxy/api-t.h>
/* The list used to transfer sockets between old and new processes */
struct xfer_sock_list {
int fd;
int options; /* socket options as LI_O_* */
char *iface;
char *namespace;
struct xfer_sock_list *prev;
struct xfer_sock_list *next;
struct sockaddr_storage addr;
};
#endif /* _HAPROXY_SOCK_T_H */
/*
* Local variables:
* c-indent-level: 8
* c-basic-offset: 8
* End:
*/

View File

@ -27,6 +27,9 @@
#include <haproxy/api.h>
#include <haproxy/connection-t.h>
#include <haproxy/sock-t.h>
extern struct xfer_sock_list *xfer_sock_list;
int sock_create_server_socket(struct connection *conn);
int sock_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);

View File

@ -117,6 +117,7 @@
#include <haproxy/server.h>
#include <haproxy/session.h>
#include <haproxy/signal.h>
#include <haproxy/sock.h>
#include <haproxy/sock_inet.h>
#include <haproxy/ssl_sock.h>
#include <haproxy/stream.h>

View File

@ -44,8 +44,6 @@ static struct bind_kw_list bind_keywords = {
.list = LIST_HEAD_INIT(bind_keywords.list)
};
struct xfer_sock_list *xfer_sock_list = NULL;
/* there is one listener queue per thread so that a thread unblocking the
* global queue can wake up listeners bound only to foreign threads by
* moving them to the remote queues and waking up the associated tasklet.

View File

@ -24,10 +24,13 @@
#include <haproxy/api.h>
#include <haproxy/connection.h>
#include <haproxy/listener-t.h>
#include <haproxy/namespace.h>
#include <haproxy/sock.h>
#include <haproxy/tools.h>
/* the list of remaining sockets transferred from an older process */
struct xfer_sock_list *xfer_sock_list = NULL;
/* Create a socket to connect to the server in conn->dst (which MUST be valid),
* using the configured namespace if needed, or the one passed by the proxy