MINOR: receiver: add a receiver-specific flag to indicate the socket is bound
In order to split the receiver from the listener, we'll need to know that
a socket is already bound and ready to receive. We used to do that via
tha LI_O_ASSIGNED state but that's not sufficient anymore since the
receiver might not belong to a listener anymore. The new RX_F_BOUND flag
is used for this.
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 90300cc..d25ab5a 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -106,6 +106,9 @@
if (listener->state != LI_ASSIGNED)
return ERR_NONE; /* already bound */
+ if (listener->rx.flags & RX_F_BOUND)
+ goto bound;
+
if (listener->rx.fd == -1) {
err |= ERR_FATAL | ERR_ALERT;
msg = "sockpair can be only used with inherited FDs";
@@ -122,7 +125,9 @@
msg = "cannot make sockpair non-blocking";
goto err_return;
}
+ listener->rx.flags |= RX_F_BOUND;
+ bound:
listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->rx.proto->accept,