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_uxst.c b/src/proto_uxst.c
index 55d02be..4378db3 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -109,6 +109,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)
listener->rx.fd = sock_find_compatible_fd(listener);
path = ((struct sockaddr_un *)&listener->rx.addr)->sun_path;
@@ -230,7 +233,9 @@
msg = "cannot change UNIX socket ownership";
goto err_unlink_temp;
}
+ listener->rx.flags |= RX_F_BOUND;
+ bound:
ready = 0;
ready_len = sizeof(ready);
if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &ready, &ready_len) == -1)