]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: protocol: remove all ->bind_all() and ->unbind_all() functions
authorWilly Tarreau <w@1wt.eu>
Tue, 1 Sep 2020 16:54:13 +0000 (18:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 2 Sep 2020 08:40:33 +0000 (10:40 +0200)
These ones were not used anymore since the two previous patches, let's
drop them.

include/haproxy/listener.h
include/haproxy/protocol-t.h
src/listener.c
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxst.c

index 996f3d8b8d51b316703e19f45afce2cc79ed0f06..9715f89aea0244582c5ecf5f92ec07fee8f273bb 100644 (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
index 247ba58f5bf8adb50837d670b0928d6bf1ceb8e6..15396275b3c089848f38226a28cf9906479c415b 100644 (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 */
index 894c93a4a04f5983ddc77601f505bad651aa9331..42ab3f2a393dc74725bf8432cccc5741ebd095d1 100644 (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
index 835ce8fe04da607d621c424304bd67c417a90dd5..18fa77029f100bff4bd5f6e25d19d83da991a701 100644 (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
index 933eced34a276721ff5482f260cc1683f07086da..56e93916ecef32399935a6eb9d1b0085a316913c 100644 (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.
index 18e46ac917011e4f75452e12e72617b951d6e2b2..be100b54c07df73227035301a8788450924bf797 100644 (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.
index 2c3e202de65758f8fe52fcfd425d5608187e8354..07e83e29c5995c5db059480be985d0ae2dfe2e73 100644 (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