MEDIUM: listeners: make use of fd_want_recv_safe() to enable early receivers

We used to refrain from calling fd_want_recv() if fd_updt was not allocated
but it's not the right solution as this does not allow the FD to be set.
Instead, let's use the new fd_want_recv_safe() which will update the FD and
create an update entry only if possible. In addition, the equivalent test
before calling fd_stop_recv() was removed as totally useless since there's
not fd_updt creation in this case.
This commit is contained in:
Willy Tarreau 2020-11-04 13:59:04 +01:00
parent 7e98e28eb0
commit a4380b211f
5 changed files with 21 additions and 33 deletions

View File

@ -107,21 +107,19 @@ static void sockpair_add_listener(struct listener *listener, int port)
}
/* Enable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void sockpair_enable_listener(struct listener *l)
{
if (fd_updt)
fd_want_recv(l->rx.fd);
fd_want_recv_safe(l->rx.fd);
}
/* Disable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void sockpair_disable_listener(struct listener *l)
{
if (fd_updt)
fd_stop_recv(l->rx.fd);
fd_stop_recv(l->rx.fd);
}
/* Binds receiver <rx>, and assigns rx->iocb and rx->owner as the callback

View File

@ -749,21 +749,19 @@ static void tcpv6_add_listener(struct listener *listener, int port)
}
/* Enable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void tcp_enable_listener(struct listener *l)
{
if (fd_updt)
fd_want_recv(l->rx.fd);
fd_want_recv_safe(l->rx.fd);
}
/* Disable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void tcp_disable_listener(struct listener *l)
{
if (fd_updt)
fd_stop_recv(l->rx.fd);
fd_stop_recv(l->rx.fd);
}
/* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver

View File

@ -173,21 +173,19 @@ static void udp6_add_listener(struct listener *listener, int port)
}
/* Enable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void udp_enable_listener(struct listener *l)
{
if (fd_updt)
fd_want_recv(l->rx.fd);
fd_want_recv_safe(l->rx.fd);
}
/* Disable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void udp_disable_listener(struct listener *l)
{
if (fd_updt)
fd_stop_recv(l->rx.fd);
fd_stop_recv(l->rx.fd);
}
/* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver

View File

@ -153,21 +153,19 @@ static void uxst_add_listener(struct listener *listener, int port)
}
/* Enable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void uxst_enable_listener(struct listener *l)
{
if (fd_updt)
fd_want_recv(l->rx.fd);
fd_want_recv_safe(l->rx.fd);
}
/* Disable receipt of incoming connections for listener <l>. The receiver must
* still be valid. Does nothing in early boot (needs fd_updt).
* still be valid.
*/
static void uxst_disable_listener(struct listener *l)
{
if (fd_updt)
fd_stop_recv(l->rx.fd);
fd_stop_recv(l->rx.fd);
}
/* Suspend a receiver. Returns < 0 in case of failure, 0 if the receiver

View File

@ -186,21 +186,17 @@ int sock_create_server_socket(struct connection *conn)
return my_socketat(ns, conn->dst->ss_family, SOCK_STREAM, 0);
}
/* Enables receiving on receiver <rx> once already bound. Does nothing in early
* boot (needs fd_updt).
*/
/* Enables receiving on receiver <rx> once already bound. */
void sock_enable(struct receiver *rx)
{
if (rx->flags & RX_F_BOUND && fd_updt)
fd_want_recv(rx->fd);
if (rx->flags & RX_F_BOUND)
fd_want_recv_safe(rx->fd);
}
/* Disables receiving on receiver <rx> once already bound. Does nothing in early
* boot (needs fd_updt).
*/
/* Disables receiving on receiver <rx> once already bound. */
void sock_disable(struct receiver *rx)
{
if (rx->flags & RX_F_BOUND && fd_updt)
if (rx->flags & RX_F_BOUND)
fd_stop_recv(rx->fd);
}