CLEANUP: protocol: remove all ->bind_all() and ->unbind_all() functions

These ones were not used anymore since the two previous patches, let's
drop them.
This commit is contained in:
Willy Tarreau 2020-09-01 18:54:13 +02:00
parent ca2126230a
commit 576a633868
7 changed files with 2 additions and 168 deletions

View File

@ -83,13 +83,6 @@ void unbind_listener(struct listener *listener);
*/
void unbind_listener_no_close(struct listener *listener);
/* This function closes all listening sockets bound to the protocol <proto>,
* and the listeners end in LI_ASSIGNED state if they were higher. It does not
* detach them from the protocol. It always returns ERR_NONE.
*/
int unbind_all_listeners(struct protocol *proto);
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
* allocation). The address family is taken from ss->ss_family. The number of

View File

@ -59,9 +59,8 @@ struct connection;
/* This structure contains all information needed to easily handle a protocol.
* Its primary goal is to ease listeners maintenance. Specifically, the
* bind_all() primitive must be used before any fork(), and the enable_all()
* primitive must be called after the fork() to enable all fds. Last, the
* unbind_all() primitive closes all listeners.
* bind() primitive must be used before any fork(), and the enable_all()
* primitive must be called after the fork() to enable all fds.
*/
struct protocol {
char name[PROTO_NAME_LEN]; /* protocol name, zero-terminated */
@ -73,8 +72,6 @@ struct protocol {
int l3_addrlen; /* layer3 address length, used by hashes */
void (*accept)(int fd); /* generic accept function */
int (*bind)(struct listener *l, char *errmsg, int errlen); /* bind a listener */
int (*bind_all)(struct protocol *proto, char *errmsg, int errlen); /* bind all unbound listeners */
int (*unbind_all)(struct protocol *proto); /* unbind all bound listeners */
int (*enable_all)(struct protocol *proto); /* enable all bound listeners */
int (*disable_all)(struct protocol *proto); /* disable all bound listeners */
int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */

View File

@ -532,22 +532,6 @@ void unbind_listener_no_close(struct listener *listener)
HA_SPIN_UNLOCK(LISTENER_LOCK, &listener->lock);
}
/* This function closes all listening sockets bound to the protocol <proto>,
* and the listeners end in LI_ASSIGNED state if they were higher. It does not
* detach them from the protocol. It always returns ERR_NONE.
*
* Must be called with proto_lock held.
*
*/
int unbind_all_listeners(struct protocol *proto)
{
struct listener *listener;
list_for_each_entry(listener, &proto->listeners, proto_list)
unbind_listener(listener);
return ERR_NONE;
}
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
* allocation). The address family is taken from ss->ss_family. The number of

View File

@ -42,7 +42,6 @@
static void sockpair_add_listener(struct listener *listener, int port);
static int sockpair_bind_listener(struct listener *listener, char *errmsg, int errlen);
static int sockpair_bind_listeners(struct protocol *proto, char *errmsg, int errlen);
static int sockpair_connect_server(struct connection *conn, int flags);
/* Note: must not be declared <const> as its list will be overwritten */
@ -57,8 +56,6 @@ static struct protocol proto_sockpair = {
.accept = &listener_accept,
.connect = &sockpair_connect_server,
.bind = sockpair_bind_listener,
.bind_all = sockpair_bind_listeners,
.unbind_all = NULL,
.enable_all = enable_all_listeners,
.disable_all = disable_all_listeners,
.get_src = NULL,
@ -88,29 +85,6 @@ static void sockpair_add_listener(struct listener *listener, int port)
proto_sockpair.nb_listeners++;
}
/* This function creates all UNIX sockets bound to the protocol entry <proto>.
* It is intended to be used as the protocol's bind_all() function.
* The sockets will be registered but not added to any fd_set, in order not to
* loose them across the fork(). A call to uxst_enable_listeners() is needed
* to complete initialization.
*
* Must be called with proto_lock held.
*
* The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
*/
static int sockpair_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
{
struct listener *listener;
int err = ERR_NONE;
list_for_each_entry(listener, &proto->listeners, proto_list) {
err |= sockpair_bind_listener(listener, errmsg, errlen);
if (err & ERR_ABORT)
break;
}
return err;
}
/* This function changes the state from ASSIGNED to LISTEN. The socket is NOT
* enabled for polling. The return value is composed from ERR_NONE,
* ERR_RETRYABLE and ERR_FATAL. It may return a warning or an error message in

View File

@ -44,7 +44,6 @@
#include <haproxy/tools.h>
static int tcp_bind_listeners(struct protocol *proto, char *errmsg, int errlen);
static int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen);
static void tcpv4_add_listener(struct listener *listener, int port);
static void tcpv6_add_listener(struct listener *listener, int port);
@ -61,8 +60,6 @@ static struct protocol proto_tcpv4 = {
.accept = &listener_accept,
.connect = tcp_connect_server,
.bind = tcp_bind_listener,
.bind_all = tcp_bind_listeners,
.unbind_all = unbind_all_listeners,
.enable_all = enable_all_listeners,
.get_src = sock_get_src,
.get_dst = sock_inet_get_dst,
@ -87,8 +84,6 @@ static struct protocol proto_tcpv6 = {
.accept = &listener_accept,
.connect = tcp_connect_server,
.bind = tcp_bind_listener,
.bind_all = tcp_bind_listeners,
.unbind_all = unbind_all_listeners,
.enable_all = enable_all_listeners,
.get_src = sock_get_src,
.get_dst = sock_get_dst,
@ -793,29 +788,6 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
goto tcp_return;
}
/* This function creates all TCP sockets bound to the protocol entry <proto>.
* It is intended to be used as the protocol's bind_all() function.
* The sockets will be registered but not added to any fd_set, in order not to
* loose them across the fork(). A call to enable_all_listeners() is needed
* to complete initialization. The return value is composed from ERR_*.
*
* Must be called with proto_lock held.
*
*/
static int tcp_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
{
struct listener *listener;
int err = ERR_NONE;
list_for_each_entry(listener, &proto->listeners, proto_list) {
err |= tcp_bind_listener(listener, errmsg, errlen);
if (err & ERR_ABORT)
break;
}
return err;
}
/* Add <listener> to the list of tcpv4 listeners, on port <port>. The
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
* The number of listeners for the protocol is updated.

View File

@ -40,7 +40,6 @@
#include <haproxy/sock_inet.h>
#include <haproxy/task.h>
static int udp_bind_listeners(struct protocol *proto, char *errmsg, int errlen);
static int udp_bind_listener(struct listener *listener, char *errmsg, int errlen);
static void udp4_add_listener(struct listener *listener, int port);
static void udp6_add_listener(struct listener *listener, int port);
@ -57,8 +56,6 @@ static struct protocol proto_udp4 = {
.accept = NULL,
.connect = NULL,
.bind = udp_bind_listener,
.bind_all = udp_bind_listeners,
.unbind_all = unbind_all_listeners,
.enable_all = enable_all_listeners,
.get_src = udp_get_src,
.get_dst = udp_get_dst,
@ -83,8 +80,6 @@ static struct protocol proto_udp6 = {
.accept = NULL,
.connect = NULL,
.bind = udp_bind_listener,
.bind_all = udp_bind_listeners,
.unbind_all = unbind_all_listeners,
.enable_all = enable_all_listeners,
.get_src = udp6_get_src,
.get_dst = udp6_get_dst,
@ -305,26 +300,6 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
goto udp_return;
}
/* This function creates all UDP sockets bound to the protocol entry <proto>.
* It is intended to be used as the protocol's bind_all() function.
* The sockets will be registered but not added to any fd_set, in order not to
* loose them across the fork(). A call to enable_all_listeners() is needed
* to complete initialization. The return value is composed from ERR_*.
*/
static int udp_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
{
struct listener *listener;
int err = ERR_NONE;
list_for_each_entry(listener, &proto->listeners, proto_list) {
err |= udp_bind_listener(listener, errmsg, errlen);
if (err & ERR_ABORT)
break;
}
return err;
}
/* Add <listener> to the list of udp4 listeners, on port <port>. The
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
* The number of listeners for the protocol is updated.

View File

@ -41,8 +41,6 @@
static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen);
static int uxst_bind_listeners(struct protocol *proto, char *errmsg, int errlen);
static int uxst_unbind_listeners(struct protocol *proto);
static int uxst_connect_server(struct connection *conn, int flags);
static void uxst_add_listener(struct listener *listener, int port);
static int uxst_pause_listener(struct listener *l);
@ -59,8 +57,6 @@ static struct protocol proto_unix = {
.accept = &listener_accept,
.connect = &uxst_connect_server,
.bind = uxst_bind_listener,
.bind_all = uxst_bind_listeners,
.unbind_all = uxst_unbind_listeners,
.enable_all = enable_all_listeners,
.disable_all = disable_all_listeners,
.get_src = sock_get_src,
@ -296,17 +292,6 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
return err;
}
/* This function closes the UNIX sockets for the specified listener.
* The listener enters the LI_ASSIGNED state. It always returns ERR_NONE.
*/
static int uxst_unbind_listener(struct listener *listener)
{
if (listener->state > LI_ASSIGNED) {
unbind_listener(listener);
}
return ERR_NONE;
}
/* Add <listener> to the list of unix stream listeners (port is ignored). The
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
* The number of listeners for the protocol is updated.
@ -521,52 +506,6 @@ static int uxst_connect_server(struct connection *conn, int flags)
return SF_ERR_NONE; /* connection is OK */
}
/********************************
* 3) protocol-oriented functions
********************************/
/* This function creates all UNIX sockets bound to the protocol entry <proto>.
* It is intended to be used as the protocol's bind_all() function.
* The sockets will be registered but not added to any fd_set, in order not to
* loose them across the fork(). A call to uxst_enable_listeners() is needed
* to complete initialization.
*
* Must be called with proto_lock held.
*
* The return value is composed from ERR_NONE, ERR_RETRYABLE and ERR_FATAL.
*/
static int uxst_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
{
struct listener *listener;
int err = ERR_NONE;
list_for_each_entry(listener, &proto->listeners, proto_list) {
err |= uxst_bind_listener(listener, errmsg, errlen);
if (err & ERR_ABORT)
break;
}
return err;
}
/* This function stops all listening UNIX sockets bound to the protocol
* <proto>. It does not detaches them from the protocol.
* It always returns ERR_NONE.
*
* Must be called with proto_lock held.
*
*/
static int uxst_unbind_listeners(struct protocol *proto)
{
struct listener *listener;
list_for_each_entry(listener, &proto->listeners, proto_list)
uxst_unbind_listener(listener);
return ERR_NONE;
}
/*
* Local variables:
* c-indent-level: 8