]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: protocol: make proto_tcp & proto_uxst report listening sockets
authorWilly Tarreau <w@1wt.eu>
Tue, 13 Oct 2020 15:26:00 +0000 (17:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Oct 2020 16:15:33 +0000 (18:15 +0200)
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.

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

index 2dea7326ea7484e648ddcafccc5415589670f30a..ae7ec1975974b0e36eed6ed4e6840f05f3420533 100644 (file)
@@ -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 */
index aadac7c07b105fee48822cf7b4907d3befb79499..fbc99c939fd85b4a2c41752e7d1ae901351ffe92 100644 (file)
@@ -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),
index 047b75954c09644d1b9c7dce4545c2eceb2db7c3..d9d5a07b00d55f8688d0621c38221385737e515e 100644 (file)
@@ -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),