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_tcp.c b/src/proto_tcp.c
index 62f8611..84b3635 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -569,6 +569,9 @@
err = ERR_NONE;
+ if (listener->rx.flags & RX_F_BOUND)
+ goto bound;
+
if (listener->rx.fd == -1)
listener->rx.fd = sock_find_compatible_fd(listener);
@@ -744,7 +747,9 @@
msg = "cannot bind socket";
goto tcp_close_return;
}
+ listener->rx.flags |= RX_F_BOUND;
+ bound:
ready = 0;
ready_len = sizeof(ready);
if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &ready, &ready_len) == -1)