MINOR: sock: rename sock_accept_conn() to sock_accepting_conn()
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Oct 2020 07:19:43 +0000 (09:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Oct 2020 19:47:56 +0000 (21:47 +0200)
This call was introduced by commit 5ced3e887 ("MINOR: sock: add
sock_accept_conn() to test a listening socket") but is actually quite
confusing because it makes one think the socket will accept a connection
(which is what we want to have in a new function) while it only tells
whether it's configured to accept connections. Let's call it
sock_accepting_conn() instead.

The same change was applied to sockpair which had the same issue.

include/haproxy/sock.h
src/proto_sockpair.c
src/proto_tcp.c
src/proto_uxst.c
src/sock.c

index 40856f4..7a9125a 100644 (file)
@@ -40,7 +40,7 @@ int sock_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
 int sock_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
 int sock_get_old_sockets(const char *unixsocket);
 int sock_find_compatible_fd(const struct receiver *rx);
-int sock_accept_conn(const struct receiver *rx);
+int sock_accepting_conn(const struct receiver *rx);
 
 #endif /* _HAPROXY_SOCK_H */
 
index 48b598b..357a5fe 100644 (file)
@@ -47,7 +47,7 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
 static void sockpair_enable_listener(struct listener *listener);
 static void sockpair_disable_listener(struct listener *listener);
 static int sockpair_connect_server(struct connection *conn, int flags);
-static int sockpair_accept_conn(const struct receiver *rx);
+static int sockpair_accepting_conn(const struct receiver *rx);
 
 struct proto_fam proto_fam_sockpair = {
        .name = "sockpair",
@@ -77,7 +77,7 @@ static struct protocol proto_sockpair = {
        .rx_unbind = sock_unbind,
        .rx_enable = sock_enable,
        .rx_disable = sock_disable,
-       .rx_listening = sockpair_accept_conn,
+       .rx_listening = sockpair_accepting_conn,
        .accept = &listener_accept,
        .connect = &sockpair_connect_server,
        .receivers = LIST_HEAD_INIT(proto_sockpair.receivers),
@@ -440,7 +440,7 @@ int recv_fd_uxst(int sock)
  * The real test consists in verifying we have a connected SOCK_STREAM of
  * family AF_UNIX.
  */
-static int sockpair_accept_conn(const struct receiver *rx)
+static int sockpair_accepting_conn(const struct receiver *rx)
 {
        struct sockaddr sa;
        socklen_t len;
index be9a25a..950daec 100644 (file)
@@ -72,7 +72,7 @@ static struct protocol proto_tcpv4 = {
        .rx_unbind = sock_unbind,
        .rx_suspend = tcp_suspend_receiver,
        .rx_resume = tcp_resume_receiver,
-       .rx_listening = sock_accept_conn,
+       .rx_listening = sock_accepting_conn,
        .accept = &listener_accept,
        .connect = tcp_connect_server,
        .receivers = LIST_HEAD_INIT(proto_tcpv4.receivers),
@@ -101,7 +101,7 @@ static struct protocol proto_tcpv6 = {
        .rx_unbind = sock_unbind,
        .rx_suspend = tcp_suspend_receiver,
        .rx_resume = tcp_resume_receiver,
-       .rx_listening = sock_accept_conn,
+       .rx_listening = sock_accepting_conn,
        .accept = &listener_accept,
        .connect = tcp_connect_server,
        .receivers = LIST_HEAD_INIT(proto_tcpv6.receivers),
@@ -678,7 +678,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
        }
 #endif
 
-       ready = sock_accept_conn(&listener->rx) > 0;
+       ready = sock_accepting_conn(&listener->rx) > 0;
 
        if (!ready && /* only listen if not already done by external process */
            listen(fd, listener_backlog(listener)) == -1) {
@@ -783,7 +783,7 @@ static int tcp_suspend_receiver(struct receiver *rx)
         * dealing with a socket that is shared with other processes doing the
         * same. Let's check if it's still accepting connections.
         */
-       ret = sock_accept_conn(rx);
+       ret = sock_accepting_conn(rx);
        if (ret <= 0) {
                /* unrecoverable or paused by another process */
                fd_stop_recv(rx->fd);
index 5cf16a7..be8525b 100644 (file)
@@ -65,7 +65,7 @@ static struct protocol proto_unix = {
        .rx_disable = sock_disable,
        .rx_unbind = sock_unbind,
        .rx_suspend = uxst_suspend_receiver,
-       .rx_listening = sock_accept_conn,
+       .rx_listening = sock_accepting_conn,
        .accept = &listener_accept,
        .connect = &uxst_connect_server,
        .receivers = LIST_HEAD_INIT(proto_unix.receivers),
@@ -111,7 +111,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
        }
 
        fd = listener->rx.fd;
-       ready = sock_accept_conn(&listener->rx) > 0;
+       ready = sock_accepting_conn(&listener->rx) > 0;
 
        if (!ready && /* only listen if not already done by external process */
            listen(fd, listener_backlog(listener)) < 0) {
index ea6e366..8f890ea 100644 (file)
@@ -471,7 +471,7 @@ int sock_find_compatible_fd(const struct receiver *rx)
  * rationale behind this is that inherited FDs may be broken and that shared
  * FDs might have been paused by another process.
  */
-int sock_accept_conn(const struct receiver *rx)
+int sock_accepting_conn(const struct receiver *rx)
 {
        int opt_val = 0;
        socklen_t opt_len = sizeof(opt_val);