From: Willy Tarreau Date: Tue, 13 Oct 2020 15:26:00 +0000 (+0200) Subject: MINOR: protocol: make proto_tcp & proto_uxst report listening sockets X-Git-Tag: v2.3-dev7~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29185140db2e1146e0363d74d551e9012ed87fba;p=thirdparty%2Fhaproxy.git MINOR: protocol: make proto_tcp & proto_uxst report listening sockets Now we introdce a new .rx_listening() function to report if a receiver is actually a listening socket. The reason for this is to help detect shared sockets that might have been broken by sibling processes. --- diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 2dea7326ea..ae7ec19759 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -101,6 +101,7 @@ struct protocol { void (*rx_unbind)(struct receiver *rx); /* unbind the receiver, most often closing the FD */ int (*rx_suspend)(struct receiver *rx); /* temporarily suspend this receiver for a soft restart */ int (*rx_resume)(struct receiver *rx); /* try to resume a temporarily suspended receiver */ + int (*rx_listening)(const struct receiver *rx); /* is the receiver listening ? 0=no, >0=OK, <0=unrecoverable */ /* functions acting on connections */ void (*accept)(int fd); /* generic accept function */ diff --git a/src/proto_tcp.c b/src/proto_tcp.c index aadac7c07b..fbc99c939f 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -72,6 +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, .accept = &listener_accept, .connect = tcp_connect_server, .receivers = LIST_HEAD_INIT(proto_tcpv4.receivers), @@ -100,6 +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, .accept = &listener_accept, .connect = tcp_connect_server, .receivers = LIST_HEAD_INIT(proto_tcpv6.receivers), diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 047b75954c..d9d5a07b00 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -65,6 +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, .accept = &listener_accept, .connect = &uxst_connect_server, .receivers = LIST_HEAD_INIT(proto_unix.receivers),