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.
diff --git a/src/sock.c b/src/sock.c
index 192559b..3e2f208 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -186,21 +186,17 @@
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);
}