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/include/haproxy/receiver-t.h b/include/haproxy/receiver-t.h
index 5b45dc2..5537d5a 100644
--- a/include/haproxy/receiver-t.h
+++ b/include/haproxy/receiver-t.h
@@ -29,6 +29,9 @@
 #include <haproxy/namespace-t.h>
 #include <haproxy/thread.h>
 
+/* Bit values for receiver->options */
+#define RX_F_BOUND              0x00000001  /* receiver already bound */
+
 /* All the settings that are used to configure a receiver */
 struct rx_settings {
 	unsigned long bind_proc;          /* bitmask of processes allowed to use these listeners */
diff --git a/src/listener.c b/src/listener.c
index 4026ea2..27476cd 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -505,6 +505,7 @@
 		fd_stop_both(listener->rx.fd);
 		if (do_close) {
 			fd_delete(listener->rx.fd);
+			listener->rx.flags &= ~RX_F_BOUND;
 			listener->rx.fd = -1;
 		}
 	}
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,
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)
diff --git a/src/proto_udp.c b/src/proto_udp.c
index 9325ba8..64ea639 100644
--- a/src/proto_udp.c
+++ b/src/proto_udp.c
@@ -195,6 +195,9 @@
 
 	err = ERR_NONE;
 
+	if (listener->rx.flags & RX_F_BOUND)
+		goto bound;
+
 	/* TODO: Implement reuse fd. Take care that to identify fd to reuse
 	 * listeners uses a special AF_CUST_ family and we MUST consider
 	 * IPPROTO (sockaddr is not enough)
@@ -276,7 +279,9 @@
 		msg = "cannot bind socket";
 		goto udp_close_return;
 	}
+	listener->rx.flags |= RX_F_BOUND;
 
+ bound:
 	/* the socket is ready */
 	listener->rx.fd = fd;
 	listener->state = LI_LISTEN;
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)