From 686fa3db5086c6deb07152915ff4f2283bb99352 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 25 Sep 2020 19:09:53 +0200 Subject: [PATCH] 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. --- include/haproxy/protocol-t.h | 2 ++ src/proto_sockpair.c | 3 +++ src/proto_tcp.c | 4 ++++ src/proto_udp.c | 4 ++++ src/proto_uxst.c | 2 ++ 5 files changed, 15 insertions(+) diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index 3d5ce82cd..fbd84193d 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 b787f95fe..4a5701c8c 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 5aa7bfd60..9574c184e 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 1181d1adc..31db44298 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 7278d51b3..1febe3e5e 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,