From 576a6338683c88febaf26e8a49e403a6a6153ab8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 1 Sep 2020 18:54:13 +0200 Subject: [PATCH] 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. --- include/haproxy/listener.h | 7 ----- include/haproxy/protocol-t.h | 7 ++--- src/listener.c | 16 ---------- src/proto_sockpair.c | 26 --------------- src/proto_tcp.c | 28 ----------------- src/proto_udp.c | 25 --------------- src/proto_uxst.c | 61 ------------------------------------ 7 files changed, 2 insertions(+), 168 deletions(-) diff --git a/include/haproxy/listener.h b/include/haproxy/listener.h index 996f3d8b8..9715f89ae 100644 --- a/include/haproxy/listener.h +++ b/include/haproxy/listener.h @@ -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 , - * 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 on sockaddr on port * range to , and possibly attached to fd (or -1 for auto * allocation). The address family is taken from ss->ss_family. The number of diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 247ba58f5..15396275b 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -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 */ diff --git a/src/listener.c b/src/listener.c index 894c93a4a..42ab3f2a3 100644 --- a/src/listener.c +++ b/src/listener.c @@ -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 , - * 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 on sockaddr on port * range to , and possibly attached to fd (or -1 for auto * allocation). The address family is taken from ss->ss_family. The number of diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index 835ce8fe0..18fa77029 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -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 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 . - * 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 diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 933eced34..56e93916e 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -44,7 +44,6 @@ #include -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 . - * 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 to the list of tcpv4 listeners, on port . The * listener's state is automatically updated from LI_INIT to LI_ASSIGNED. * The number of listeners for the protocol is updated. diff --git a/src/proto_udp.c b/src/proto_udp.c index 18e46ac91..be100b54c 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -40,7 +40,6 @@ #include #include -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 . - * 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 to the list of udp4 listeners, on port . The * listener's state is automatically updated from LI_INIT to LI_ASSIGNED. * The number of listeners for the protocol is updated. diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 2c3e202de..07e83e29c 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -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 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 . - * 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 - * . 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