From 7d053e4211fb4cf6def877b91d94b3796e7d34ff Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 15 Oct 2020 09:19:43 +0200 Subject: [PATCH] MINOR: sock: rename sock_accept_conn() to sock_accepting_conn() 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 | 2 +- src/proto_sockpair.c | 6 +++--- src/proto_tcp.c | 8 ++++---- src/proto_uxst.c | 4 ++-- src/sock.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/haproxy/sock.h b/include/haproxy/sock.h index 40856f4..7a9125a 100644 --- a/include/haproxy/sock.h +++ b/include/haproxy/sock.h @@ -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 */ diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index 48b598b..357a5fe 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -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; diff --git a/src/proto_tcp.c b/src/proto_tcp.c index be9a25a..950daec 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -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); diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 5cf16a7..be8525b 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -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) { diff --git a/src/sock.c b/src/sock.c index ea6e366..8f890ea 100644 --- a/src/sock.c +++ b/src/sock.c @@ -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); -- 1.7.10.4