MEDIUM: connection: remove the intermediary polling state from the connection

Historically we used to require that the connections held the desired
polling states for the data layer and the socket layer. Then with muxes
these were more or less merged into the transport layer, and now it
happens that with all transport layers having their own state, the
"transport layer state" as we have it in the connection (XPRT_RD_ENA,
XPRT_WR_ENA) is only an exact copy of the undelying file descriptor
state, but with a delay. All of this is causing some difficulties at
many places in the code because there are still some locations which
use the conn_want_* API to remain clean and only rely on connection,
and count on a later collection call to conn_cond_update_polling(),
while others need an immediate action and directly use the FD updates.

Since our updates are now much cheaper, most of them being only an
atomic test-and-set operation, and since our I/O callbacks are deferred,
there's no benefit anymore in trying to "cache" the transient state
change in the connection flags hoping to cancel them before they
become an FD event. Better make such calls transparent indirections
to the FD layer instead and get rid of the deferred operations which
needlessly complicate the logic inside.

This removes flags CO_FL_XPRT_{RD,WR}_ENA and CO_FL_WILL_UPDATE.
A number of functions related to polling updates were either greatly
simplified or removed.

Two places were using CO_FL_XPRT_WR_ENA as a hint to know if more data
were expected to be sent after a PROXY protocol or SOCKSv4 header. These
ones were simply replaced with a check on the subscription which is
where we ought to get the autoritative information from.

Now the __conn_xprt_want_* and their conn_xprt_want_* counterparts
are the same. conn_stop_polling() and conn_xprt_stop_both() are the
same as well. conn_cond_update_polling() only causes errors to stop
polling. It also becomes way more obvious that muxes should not at
all employ conn_xprt_{want|stop}_{recv,send}(), and that the call
to __conn_xprt_stop_recv() in case a mux failed to allocate a buffer
is inappropriate, it ought to unsubscribe from reads instead. All of
this definitely requires a serious cleanup.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index af0eaae..7fb41af 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -163,48 +163,20 @@
 	conn->flags &= ~CO_FL_XPRT_TRACKED;
 }
 
-/* Update polling on connection <c>'s file descriptor depending on its current
- * state as reported in the connection's CO_FL_XPRT_* flags. The connection
- * flags are updated with the new flags at the end of the operation. Polling
- * is totally disabled if an error was reported.
- */
-void conn_update_xprt_polling(struct connection *c);
-
-/* Automatically updates polling on connection <c> depending on the XPRT flags.
- * It does nothing if CO_FL_WILL_UPDATE is present, indicating that an upper
- * caller is going to do it again later.
- */
-static inline void conn_cond_update_xprt_polling(struct connection *c)
-{
-	if (!(c->flags & CO_FL_WILL_UPDATE))
-		conn_update_xprt_polling(c);
-}
-
 /* Stop all polling on the fd. This might be used when an error is encountered
- * for example. It does not propage the change to the fd layer if
- * CO_FL_WILL_UPDATE is present, indicating that an upper caller is going to do
- * it later.
+ * for example.
  */
 static inline void conn_stop_polling(struct connection *c)
 {
-	c->flags &= ~(CO_FL_XPRT_RD_ENA | CO_FL_XPRT_WR_ENA);
-	if (!(c->flags & CO_FL_WILL_UPDATE) && conn_ctrl_ready(c))
+	if (conn_ctrl_ready(c))
 		fd_stop_both(c->handle.fd);
 }
 
-/* Automatically update polling on connection <c> depending on the XPRT and
- * SOCK flags, and on whether a handshake is in progress or not. This may be
- * called at any moment when there is a doubt about the effectiveness of the
- * polling state, for instance when entering or leaving the handshake state.
- * It does nothing if CO_FL_WILL_UPDATE is present, indicating that an upper
- * caller is going to do it again later.
- */
+/* Stops polling in case of error on the connection. */
 static inline void conn_cond_update_polling(struct connection *c)
 {
 	if (unlikely(c->flags & CO_FL_ERROR))
 		conn_stop_polling(c);
-	else if (!(c->flags & CO_FL_WILL_UPDATE))
-		conn_update_xprt_polling(c);
 }
 
 /***** Event manipulation primitives for use by DATA I/O callbacks *****/
@@ -214,57 +186,57 @@
  */
 static inline void __conn_xprt_want_recv(struct connection *c)
 {
-	c->flags |= CO_FL_XPRT_RD_ENA;
+	if (conn_ctrl_ready(c))
+		fd_want_recv(c->handle.fd);
 }
 
 static inline void __conn_xprt_stop_recv(struct connection *c)
 {
-	c->flags &= ~CO_FL_XPRT_RD_ENA;
+	if (conn_ctrl_ready(c))
+		fd_stop_recv(c->handle.fd);
 }
 
 static inline void __conn_xprt_want_send(struct connection *c)
 {
-	c->flags |= CO_FL_XPRT_WR_ENA;
+	if (conn_ctrl_ready(c))
+		fd_want_send(c->handle.fd);
 }
 
 static inline void __conn_xprt_stop_send(struct connection *c)
 {
-	c->flags &= ~CO_FL_XPRT_WR_ENA;
+	if (conn_ctrl_ready(c))
+		fd_stop_send(c->handle.fd);
 }
 
 static inline void __conn_xprt_stop_both(struct connection *c)
 {
-	c->flags &= ~(CO_FL_XPRT_WR_ENA | CO_FL_XPRT_RD_ENA);
+	if (conn_ctrl_ready(c))
+		fd_stop_both(c->handle.fd);
 }
 
 static inline void conn_xprt_want_recv(struct connection *c)
 {
 	__conn_xprt_want_recv(c);
-	conn_cond_update_xprt_polling(c);
 }
 
 static inline void conn_xprt_stop_recv(struct connection *c)
 {
 	__conn_xprt_stop_recv(c);
-	conn_cond_update_xprt_polling(c);
 }
 
 static inline void conn_xprt_want_send(struct connection *c)
 {
 	__conn_xprt_want_send(c);
-	conn_cond_update_xprt_polling(c);
 }
 
 static inline void conn_xprt_stop_send(struct connection *c)
 {
 	__conn_xprt_stop_send(c);
-	conn_cond_update_xprt_polling(c);
 }
 
 static inline void conn_xprt_stop_both(struct connection *c)
 {
 	__conn_xprt_stop_both(c);
-	conn_cond_update_xprt_polling(c);
 }
 
 /* read shutdown, called from the rcv_buf/rcv_pipe handlers when
@@ -290,7 +262,6 @@
 {
 	c->flags |= CO_FL_SOCK_WR_SH;
 	__conn_xprt_stop_send(c);
-	conn_cond_update_xprt_polling(c);
 
 	/* don't perform a clean shutdown if we're going to reset or
 	 * if the shutr was already received.
diff --git a/include/types/connection.h b/include/types/connection.h
index 74b550a..52c7c7e 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -141,18 +141,18 @@
 
 	/* Do not change these values without updating conn_*_poll_changes() ! */
 	/* unused : 0x00000001 */
-	CO_FL_XPRT_RD_ENA   = 0x00000002,  /* receiving data is allowed */
+	/* unused : 0x00000002 */
 	/* unused : 0x00000004, 0x00000008 */
 
 	/* unused : 0x00000010 */
-	CO_FL_XPRT_WR_ENA   = 0x00000020,  /* sending data is desired */
+	/* unused : 0x00000020 */
 	/* unused : 0x00000040, 0x00000080 */
 
 	/* These flags indicate whether the Control and Transport layers are initialized */
 	CO_FL_CTRL_READY    = 0x00000100, /* FD was registered, fd_delete() needed */
 	CO_FL_XPRT_READY    = 0x00000200, /* xprt_init() done, xprt_close() needed */
 
-	CO_FL_WILL_UPDATE   = 0x00000400, /* the conn handler will take care of updating the polling */
+	/* unused : 0x00000400 */
 
 	/* This flag is used by data layers to indicate they had to stop
 	 * receiving data because a buffer was full. The connection handler