diff --git a/include/haproxy/protocol-t.h b/include/haproxy/protocol-t.h index fbd84193d..c5b93ed2a 100644 --- a/include/haproxy/protocol-t.h +++ b/include/haproxy/protocol-t.h @@ -89,6 +89,8 @@ struct protocol { /* functions acting on the listener */ void (*add)(struct listener *l, int port); /* add a listener for this protocol and port */ int (*listen)(struct listener *l, char *errmsg, int errlen); /* start a listener */ + void (*enable)(struct listener *l); /* enable receipt of new connections */ + void (*disable)(struct listener *l); /* disable receipt of new connections */ /* functions acting on the receiver */ void (*rx_enable)(struct receiver *rx); /* enable receiving on the receiver */ diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index 4a5701c8c..f43aa8229 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -44,6 +44,8 @@ static void sockpair_add_listener(struct listener *listener, int port); static int sockpair_bind_listener(struct listener *listener, char *errmsg, int errlen); +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); struct proto_fam proto_fam_sockpair = { @@ -68,6 +70,8 @@ static struct protocol proto_sockpair = { .sock_prot = 0, .add = sockpair_add_listener, .listen = sockpair_bind_listener, + .enable = sockpair_enable_listener, + .disable = sockpair_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .accept = &listener_accept, @@ -95,6 +99,24 @@ static void sockpair_add_listener(struct listener *listener, int port) proto_sockpair.nb_receivers++; } +/* Enable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void sockpair_enable_listener(struct listener *l) +{ + if (fd_updt) + fd_want_recv(l->rx.fd); +} + +/* Disable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void sockpair_disable_listener(struct listener *l) +{ + if (fd_updt) + fd_stop_recv(l->rx.fd); +} + /* Binds receiver , and assigns and rx->owner as the callback and * context, respectively, with as the thread mask. Returns and error code * made of ERR_* bits on failure or ERR_NONE on success. On failure, an error diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 9574c184e..b12cf724b 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -47,6 +47,8 @@ static int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen); static int tcp_suspend_receiver(struct receiver *rx); static int tcp_resume_receiver(struct receiver *rx); +static void tcp_enable_listener(struct listener *listener); +static void tcp_disable_listener(struct listener *listener); static void tcpv4_add_listener(struct listener *listener, int port); static void tcpv6_add_listener(struct listener *listener, int port); @@ -60,6 +62,8 @@ static struct protocol proto_tcpv4 = { .sock_prot = IPPROTO_TCP, .add = tcpv4_add_listener, .listen = tcp_bind_listener, + .enable = tcp_enable_listener, + .disable = tcp_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .rx_suspend = tcp_suspend_receiver, @@ -82,6 +86,8 @@ static struct protocol proto_tcpv6 = { .sock_prot = IPPROTO_TCP, .add = tcpv6_add_listener, .listen = tcp_bind_listener, + .enable = tcp_enable_listener, + .disable = tcp_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .rx_suspend = tcp_suspend_receiver, @@ -733,6 +739,24 @@ static void tcpv6_add_listener(struct listener *listener, int port) proto_tcpv6.nb_receivers++; } +/* Enable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void tcp_enable_listener(struct listener *l) +{ + if (fd_updt) + fd_want_recv(l->rx.fd); +} + +/* Disable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void tcp_disable_listener(struct listener *l) +{ + if (fd_updt) + fd_stop_recv(l->rx.fd); +} + /* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver * was totally stopped, or > 0 if correctly suspended. */ diff --git a/src/proto_udp.c b/src/proto_udp.c index 31db44298..33a4dca46 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -42,6 +42,8 @@ static int udp_bind_listener(struct listener *listener, char *errmsg, int errlen); static int udp_suspend_receiver(struct receiver *rx); +static void udp_enable_listener(struct listener *listener); +static void udp_disable_listener(struct listener *listener); static void udp4_add_listener(struct listener *listener, int port); static void udp6_add_listener(struct listener *listener, int port); @@ -55,6 +57,8 @@ static struct protocol proto_udp4 = { .sock_prot = IPPROTO_UDP, .add = udp4_add_listener, .listen = udp_bind_listener, + .enable = udp_enable_listener, + .disable = udp_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .rx_suspend = udp_suspend_receiver, @@ -74,6 +78,8 @@ static struct protocol proto_udp6 = { .sock_prot = IPPROTO_UDP, .add = udp6_add_listener, .listen = udp_bind_listener, + .enable = udp_enable_listener, + .disable = udp_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .rx_suspend = udp_suspend_receiver, @@ -155,6 +161,24 @@ static void udp6_add_listener(struct listener *listener, int port) proto_udp6.nb_receivers++; } +/* Enable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void udp_enable_listener(struct listener *l) +{ + if (fd_updt) + fd_want_recv(l->rx.fd); +} + +/* Disable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void udp_disable_listener(struct listener *l) +{ + if (fd_updt) + fd_stop_recv(l->rx.fd); +} + /* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver * was totally stopped, or > 0 if correctly suspended. */ diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 1febe3e5e..4ec672ffc 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -43,6 +43,8 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errlen); static int uxst_connect_server(struct connection *conn, int flags); static void uxst_add_listener(struct listener *listener, int port); +static void uxst_enable_listener(struct listener *listener); +static void uxst_disable_listener(struct listener *listener); static int uxst_suspend_receiver(struct receiver *rx); /* Note: must not be declared as its list will be overwritten */ @@ -55,6 +57,8 @@ static struct protocol proto_unix = { .sock_prot = 0, .add = uxst_add_listener, .listen = uxst_bind_listener, + .enable = uxst_enable_listener, + .disable = uxst_disable_listener, .rx_enable = sock_enable, .rx_disable = sock_disable, .rx_suspend = uxst_suspend_receiver, @@ -148,6 +152,24 @@ static void uxst_add_listener(struct listener *listener, int port) proto_unix.nb_receivers++; } +/* Enable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void uxst_enable_listener(struct listener *l) +{ + if (fd_updt) + fd_want_recv(l->rx.fd); +} + +/* Disable receipt of incoming connections for listener . The receiver must + * still be valid. Does nothing in early boot (needs fd_updt). + */ +static void uxst_disable_listener(struct listener *l) +{ + if (fd_updt) + fd_stop_recv(l->rx.fd); +} + /* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver * was totally stopped, or > 0 if correctly suspended. Nothing is done for * plain unix sockets since currently it's the new process which handles