From: Willy Tarreau Date: Fri, 25 Sep 2020 17:09:53 +0000 (+0200) Subject: MINOR: protocol: add a new pair of rx_enable/rx_disable methods X-Git-Tag: v2.3-dev6~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=686fa3db5086c6deb07152915ff4f2283bb99352;p=thirdparty%2Fhaproxy.git MINOR: protocol: add a new pair of rx_enable/rx_disable methods These methods will be used to enable/disable rx at the receiver level so that callers don't play with FDs directly anymore. All our protocols use the generic ones from sock.c at the moment. For now they're not used. --- diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 3d5ce82cdc..fbd84193db 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -91,6 +91,8 @@ struct protocol { int (*listen)(struct listener *l, char *errmsg, int errlen); /* start a listener */ /* functions acting on the receiver */ + void (*rx_enable)(struct receiver *rx); /* enable receiving on the receiver */ + void (*rx_disable)(struct receiver *rx); /* disable receiving on the receiver */ 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 */ diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index b787f95fe8..4a5701c8cf 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,8 @@ static struct protocol proto_sockpair = { .sock_prot = 0, .add = sockpair_add_listener, .listen = sockpair_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .accept = &listener_accept, .connect = &sockpair_connect_server, .receivers = LIST_HEAD_INIT(proto_sockpair.receivers), diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 5aa7bfd60f..9574c184e5 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -60,6 +60,8 @@ static struct protocol proto_tcpv4 = { .sock_prot = IPPROTO_TCP, .add = tcpv4_add_listener, .listen = tcp_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .rx_suspend = tcp_suspend_receiver, .rx_resume = tcp_resume_receiver, .accept = &listener_accept, @@ -80,6 +82,8 @@ static struct protocol proto_tcpv6 = { .sock_prot = IPPROTO_TCP, .add = tcpv6_add_listener, .listen = tcp_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .rx_suspend = tcp_suspend_receiver, .rx_resume = tcp_resume_receiver, .accept = &listener_accept, diff --git a/src/proto_udp.c b/src/proto_udp.c index 1181d1adc4..31db442986 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -55,6 +55,8 @@ static struct protocol proto_udp4 = { .sock_prot = IPPROTO_UDP, .add = udp4_add_listener, .listen = udp_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .rx_suspend = udp_suspend_receiver, .receivers = LIST_HEAD_INIT(proto_udp4.receivers), .nb_receivers = 0, @@ -72,6 +74,8 @@ static struct protocol proto_udp6 = { .sock_prot = IPPROTO_UDP, .add = udp6_add_listener, .listen = udp_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .rx_suspend = udp_suspend_receiver, .receivers = LIST_HEAD_INIT(proto_udp6.receivers), .nb_receivers = 0, diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 7278d51b3e..1febe3e5ef 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -55,6 +55,8 @@ static struct protocol proto_unix = { .sock_prot = 0, .add = uxst_add_listener, .listen = uxst_bind_listener, + .rx_enable = sock_enable, + .rx_disable = sock_disable, .rx_suspend = uxst_suspend_receiver, .accept = &listener_accept, .connect = &uxst_connect_server,