MEDIUM: connections: Remove CONN_FL_SOCK*

Now that the various handshakes come with their own XPRT, there's no
need for the CONN_FL_SOCK* flags, and the conn_sock_want|stop functions,
so garbage-collect them.
diff --git a/include/proto/connection.h b/include/proto/connection.h
index ac4e5de..67177c5 100644
--- a/include/proto/connection.h
+++ b/include/proto/connection.h
@@ -160,14 +160,6 @@
 
 /* Update polling on connection <c>'s file descriptor depending on its current
  * state as reported in the connection's CO_FL_CURR_* flags, reports of EAGAIN
- * in CO_FL_WAIT_*, and the sock layer expectations indicated by CO_FL_SOCK_*.
- * 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_sock_polling(struct connection *c);
-
-/* Update polling on connection <c>'s file descriptor depending on its current
- * state as reported in the connection's CO_FL_CURR_* flags, reports of EAGAIN
  * in CO_FL_WAIT_*, and the upper layer expectations indicated by CO_FL_XPRT_*.
  * The connection flags are updated with the new flags at the end of the
  * operation. Polling is totally disabled if an error was reported.
@@ -216,51 +208,17 @@
 	return f & (CO_FL_CURR_WR_ENA | CO_FL_CURR_RD_ENA | CO_FL_ERROR);
 }
 
-/* inspects c->flags and returns non-zero if SOCK ENA changes from the CURR ENA
- * or if the WAIT flags are set with their respective ENA flags. Additionally,
- * non-zero is also returned if an error was reported on the connection. This
- * function is used quite often and is inlined. In order to proceed optimally
- * with very little code and CPU cycles, the bits are arranged so that a change
- * can be detected by a few left shifts, a xor, and a mask. These operations
- * detect when W&S are both enabled for either direction, when C&S differ for
- * either direction and when Error is set. The trick consists in first keeping
- * only the bits we're interested in, since they don't collide when shifted,
- * and to perform the AND at the end. In practice, the compiler is able to
- * replace the last AND with a TEST in boolean conditions. This results in
- * checks that are done in 4-6 cycles and less than 30 bytes.
- */
-static inline unsigned int conn_sock_polling_changes(const struct connection *c)
-{
-	unsigned int f = c->flags;
-	f &= CO_FL_SOCK_WR_ENA | CO_FL_SOCK_RD_ENA | CO_FL_CURR_WR_ENA |
-	     CO_FL_CURR_RD_ENA | CO_FL_ERROR;
-
-	f = (f ^ (f << 2)) & (CO_FL_CURR_WR_ENA|CO_FL_CURR_RD_ENA);    /* test C ^ S */
-	return f & (CO_FL_CURR_WR_ENA | CO_FL_CURR_RD_ENA | CO_FL_ERROR);
-}
-
-/* Automatically updates polling on connection <c> depending on the XPRT flags
- * if no handshake is in progress. It does nothing if CO_FL_WILL_UPDATE is
- * present, indicating that an upper caller is going to do it again later.
+/* 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))
-		if (!(c->flags & CO_FL_POLL_SOCK) && conn_xprt_polling_changes(c))
+		if (conn_xprt_polling_changes(c))
 			conn_update_xprt_polling(c);
 }
 
-/* Automatically updates polling on connection <c> depending on the SOCK flags
- * if a handshake is in progress. 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_sock_polling(struct connection *c)
-{
-	if (!(c->flags & CO_FL_WILL_UPDATE))
-		if ((c->flags & CO_FL_POLL_SOCK) && conn_sock_polling_changes(c))
-			conn_update_sock_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
@@ -269,7 +227,6 @@
 static inline void conn_stop_polling(struct connection *c)
 {
 	c->flags &= ~(CO_FL_CURR_RD_ENA | CO_FL_CURR_WR_ENA |
-		      CO_FL_SOCK_RD_ENA | CO_FL_SOCK_WR_ENA |
 		      CO_FL_XPRT_RD_ENA | CO_FL_XPRT_WR_ENA);
 	if (!(c->flags & CO_FL_WILL_UPDATE) && conn_ctrl_ready(c))
 		fd_stop_both(c->handle.fd);
@@ -287,10 +244,8 @@
 	if (unlikely(c->flags & CO_FL_ERROR))
 		conn_stop_polling(c);
 	else if (!(c->flags & CO_FL_WILL_UPDATE)) {
-		if (!(c->flags & CO_FL_POLL_SOCK) && conn_xprt_polling_changes(c))
+		if (conn_xprt_polling_changes(c))
 			conn_update_xprt_polling(c);
-		else if ((c->flags & CO_FL_POLL_SOCK) && conn_sock_polling_changes(c))
-			conn_update_sock_polling(c);
 	}
 }
 
@@ -368,73 +323,13 @@
 	conn_cond_update_xprt_polling(c);
 }
 
-/***** Event manipulation primitives for use by handshake I/O callbacks *****/
-/* The __conn_* versions do not propagate to lower layers and are only meant
- * to be used by handlers called by the connection handler. The other ones
- * may be used anywhere.
- */
-static inline void __conn_sock_want_recv(struct connection *c)
-{
-	c->flags |= CO_FL_SOCK_RD_ENA;
-}
-
-static inline void __conn_sock_stop_recv(struct connection *c)
-{
-	c->flags &= ~CO_FL_SOCK_RD_ENA;
-}
-
-static inline void __conn_sock_want_send(struct connection *c)
-{
-	c->flags |= CO_FL_SOCK_WR_ENA;
-}
-
-static inline void __conn_sock_stop_send(struct connection *c)
-{
-	c->flags &= ~CO_FL_SOCK_WR_ENA;
-}
-
-static inline void __conn_sock_stop_both(struct connection *c)
-{
-	c->flags &= ~(CO_FL_SOCK_WR_ENA | CO_FL_SOCK_RD_ENA);
-}
-
-static inline void conn_sock_want_recv(struct connection *c)
-{
-	__conn_sock_want_recv(c);
-	conn_cond_update_sock_polling(c);
-}
-
-static inline void conn_sock_stop_recv(struct connection *c)
-{
-	__conn_sock_stop_recv(c);
-	conn_cond_update_sock_polling(c);
-}
-
-static inline void conn_sock_want_send(struct connection *c)
-{
-	__conn_sock_want_send(c);
-	conn_cond_update_sock_polling(c);
-}
-
-static inline void conn_sock_stop_send(struct connection *c)
-{
-	__conn_sock_stop_send(c);
-	conn_cond_update_sock_polling(c);
-}
-
-static inline void conn_sock_stop_both(struct connection *c)
-{
-	__conn_sock_stop_both(c);
-	conn_cond_update_sock_polling(c);
-}
-
 /* read shutdown, called from the rcv_buf/rcv_pipe handlers when
  * detecting an end of connection.
  */
 static inline void conn_sock_read0(struct connection *c)
 {
 	c->flags |= CO_FL_SOCK_RD_SH;
-	__conn_sock_stop_recv(c);
+	__conn_xprt_stop_recv(c);
 	/* we don't risk keeping ports unusable if we found the
 	 * zero from the other side.
 	 */
@@ -451,8 +346,8 @@
 {
 	c->flags |= CO_FL_SOCK_WR_SH;
 	conn_refresh_polling_flags(c);
-	__conn_sock_stop_send(c);
-	conn_cond_update_sock_polling(c);
+	__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 e706b87..54f8d1a 100644
--- a/include/types/connection.h
+++ b/include/types/connection.h
@@ -136,12 +136,12 @@
 	CO_FL_NONE          = 0x00000000,  /* Just for initialization purposes */
 
 	/* Do not change these values without updating conn_*_poll_changes() ! */
-	CO_FL_SOCK_RD_ENA   = 0x00000001,  /* receiving handshakes is allowed */
+	/* unusued : 0x00000001 */
 	CO_FL_XPRT_RD_ENA   = 0x00000002,  /* receiving data is allowed */
 	CO_FL_CURR_RD_ENA   = 0x00000004,  /* receiving is currently allowed */
 	/* unused : 0x00000008 */
 
-	CO_FL_SOCK_WR_ENA   = 0x00000010,  /* sending handshakes is desired */
+	/* unused : 0x00000010 */
 	CO_FL_XPRT_WR_ENA   = 0x00000020,  /* sending data is desired */
 	CO_FL_CURR_WR_ENA   = 0x00000040,  /* sending is currently desired */
 	/* unused : 0x00000080 */
@@ -194,13 +194,6 @@
 	CO_FL_HANDSHAKE     = CO_FL_SEND_PROXY | CO_FL_SSL_WAIT_HS | CO_FL_ACCEPT_PROXY | CO_FL_ACCEPT_CIP | CO_FL_SOCKS4_SEND | CO_FL_SOCKS4_RECV,
 	CO_FL_HANDSHAKE_NOSSL = CO_FL_SEND_PROXY | CO_FL_ACCEPT_PROXY | CO_FL_ACCEPT_CIP | CO_FL_SOCKS4_SEND | CO_FL_SOCKS4_RECV,
 
-	/* when any of these flags is set, polling is defined by socket-layer
-	 * operations, as opposed to data-layer. Transport is explicitly not
-	 * mentionned here to avoid any confusion, since it can be the same
-	 * as DATA or SOCK on some implementations.
-	 */
-	CO_FL_POLL_SOCK     = CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN,
-
 	/* This connection may not be shared between clients */
 	CO_FL_PRIVATE       = 0x10000000,
 
diff --git a/src/connection.c b/src/connection.c
index 838d8fd..380d58c 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -58,15 +58,6 @@
 
 	flags = conn->flags & ~CO_FL_ERROR; /* ensure to call the wake handler upon error */
 
-	if (conn->flags & CO_FL_HANDSHAKE) {
-		if (!conn->send_wait)
-			__conn_sock_stop_send(conn);
-		if (!conn->recv_wait)
-			__conn_sock_stop_recv(conn);
-	}
-	if (!(conn->flags & CO_FL_POLL_SOCK))
-		__conn_sock_stop_both(conn);
-
 	/* The connection owner might want to be notified about an end of
 	 * handshake indicating the connection is ready, before we proceed with
 	 * any data exchange. The callback may fail and cause the connection to
@@ -197,41 +188,6 @@
 	c->flags = f;
 }
 
-/* Update polling on connection <c>'s file descriptor depending on its current
- * state as reported in the connection's CO_FL_CURR_* flags, reports of EAGAIN
- * in CO_FL_WAIT_*, and the sock layer expectations indicated by CO_FL_SOCK_*.
- * 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_sock_polling(struct connection *c)
-{
-	unsigned int f = c->flags;
-
-	if (!conn_ctrl_ready(c))
-		return;
-
-	/* update read status if needed */
-	if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_SOCK_RD_ENA)) == CO_FL_SOCK_RD_ENA)) {
-		fd_want_recv(c->handle.fd);
-		f |= CO_FL_CURR_RD_ENA;
-	}
-	else if (unlikely((f & (CO_FL_CURR_RD_ENA|CO_FL_SOCK_RD_ENA)) == CO_FL_CURR_RD_ENA)) {
-		fd_stop_recv(c->handle.fd);
-		f &= ~CO_FL_CURR_RD_ENA;
-	}
-
-	/* update write status if needed */
-	if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_SOCK_WR_ENA)) == CO_FL_SOCK_WR_ENA)) {
-		fd_want_send(c->handle.fd);
-		f |= CO_FL_CURR_WR_ENA;
-	}
-	else if (unlikely((f & (CO_FL_CURR_WR_ENA|CO_FL_SOCK_WR_ENA)) == CO_FL_CURR_WR_ENA)) {
-		fd_stop_send(c->handle.fd);
-		f &= ~CO_FL_CURR_WR_ENA;
-	}
-	c->flags = f;
-}
-
 /* Send a message over an established connection. It makes use of send() and
  * returns the same return code and errno. If the socket layer is not ready yet
  * then -1 is returned and ENOTSOCK is set into errno. If the fd is not marked
@@ -704,12 +660,9 @@
 
 	conn->flags &= ~flag;
 	conn->flags |= CO_FL_RCVD_PROXY;
-	__conn_sock_stop_recv(conn);
 	return 1;
 
  not_ready:
-	__conn_sock_want_recv(conn);
-	__conn_sock_stop_send(conn);
 	return 0;
 
  missing:
@@ -731,7 +684,6 @@
 	goto fail;
 
  fail:
-	__conn_sock_stop_both(conn);
 	conn->flags |= CO_FL_ERROR;
 	return 0;
 }
@@ -908,12 +860,9 @@
 	} while (0);
 
 	conn->flags &= ~flag;
-	__conn_sock_stop_recv(conn);
 	return 1;
 
  not_ready:
-	__conn_sock_want_recv(conn);
-	__conn_sock_stop_send(conn);
 	return 0;
 
  missing:
@@ -934,7 +883,6 @@
 	goto fail;
 
  fail:
-	__conn_sock_stop_both(conn);
 	conn->flags |= CO_FL_ERROR;
 	return 0;
 }
@@ -991,7 +939,6 @@
 
 	/* OK we've the whole request sent */
 	conn->flags &= ~CO_FL_SOCKS4_SEND;
-	__conn_sock_stop_send(conn);
 
 	/* The connection is ready now, simply return and let the connection
 	 * handler notify upper layers if needed.
@@ -1018,8 +965,6 @@
 	return 0;
 
  out_wait:
-	__conn_sock_stop_recv(conn);
-	__conn_sock_want_send(conn);
 	return 0;
 }
 
@@ -1125,12 +1070,9 @@
 	} while (0);
 
 	conn->flags &= ~CO_FL_SOCKS4_RECV;
-	__conn_sock_stop_recv(conn);
 	return 1;
 
  not_ready:
-	__conn_sock_want_recv(conn);
-	__conn_sock_stop_send(conn);
 	return 0;
 
  recv_abort:
@@ -1141,7 +1083,6 @@
 	goto fail;
 
  fail:
-	__conn_sock_stop_both(conn);
 	conn->flags |= CO_FL_ERROR;
 	return 0;
 }
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index 97a9348..a4faa37 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -327,20 +327,7 @@
 		return SF_ERR_RESOURCE;
 	}
 
-	if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN)) {
-		conn_sock_want_send(conn);  /* for connect status, proxy protocol or SSL */
-	}
-	else {
-		/* If there's no more handshake, we need to notify the data
-		 * layer when the connection is already OK otherwise we'll have
-		 * no other opportunity to do it later (eg: health checks).
-		 */
-		flags |= CONNECT_HAS_DATA;
-	}
-
-	if (flags & CONNECT_HAS_DATA)
-		conn_xprt_want_send(conn);  /* prepare to send data if any */
-
+	conn_xprt_want_send(conn);  /* for connect status, proxy protocol or SSL */
 	return SF_ERR_NONE;  /* connection is OK */
 }
 
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 7ae28f0..c64e48c 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -578,22 +578,7 @@
 		return SF_ERR_RESOURCE;
 	}
 
-	if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN | CO_FL_EARLY_SSL_HS)) {
-		conn_sock_want_send(conn);  /* for connect status, proxy protocol or SSL */
-		if (conn->flags & CO_FL_EARLY_SSL_HS)
-			conn_xprt_want_send(conn);
-	}
-	else {
-		/* If there's no more handshake, we need to notify the data
-		 * layer when the connection is already OK otherwise we'll have
-		 * no other opportunity to do it later (eg: health checks).
-		 */
-		flags |= CONNECT_HAS_DATA;
-	}
-
-	if (flags & CONNECT_HAS_DATA)
-		conn_xprt_want_send(conn);  /* prepare to send data if any */
-
+	conn_xprt_want_send(conn);  /* for connect status, proxy protocol or SSL */
 	return SF_ERR_NONE;  /* connection is OK */
 }
 
@@ -706,7 +691,7 @@
 
 	if (connect(fd, (const struct sockaddr *)addr, get_addr_len(addr)) == -1) {
 		if (errno == EALREADY || errno == EINPROGRESS) {
-			__conn_sock_stop_recv(conn);
+			__conn_xprt_stop_recv(conn);
 			fd_cant_send(fd);
 			return 0;
 		}
@@ -730,7 +715,7 @@
 	 */
 	fdtab[fd].linger_risk = 0;
 	conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH;
-	__conn_sock_stop_both(conn);
+	__conn_xprt_stop_both(conn);
 	return 0;
 }
 
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index 42e0dc8..66093af 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -578,20 +578,7 @@
 		return SF_ERR_RESOURCE;
 	}
 
-	if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN)) {
-		conn_sock_want_send(conn);  /* for connect status, proxy protocol or SSL */
-	}
-	else {
-		/* If there's no more handshake, we need to notify the data
-		 * layer when the connection is already OK otherwise we'll have
-		 * no other opportunity to do it later (eg: health checks).
-		 */
-		flags |= CONNECT_HAS_DATA;
-	}
-
-	if (flags & CONNECT_HAS_DATA)
-		conn_xprt_want_send(conn);  /* prepare to send data if any */
-
+	conn_xprt_want_send(conn);  /* for connect status, proxy protocol or SSL */
 	return SF_ERR_NONE;  /* connection is OK */
 }
 
diff --git a/src/raw_sock.c b/src/raw_sock.c
index ad9f792..cc99669 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -157,7 +157,6 @@
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 
  leave:
-	conn_cond_update_sock_polling(conn);
 	if (retval > 0) {
 		/* we count the total bytes sent, and the send rate for 32-byte
 		 * blocks. The reason for the latter is that freq_ctr are
@@ -211,7 +210,6 @@
 	if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 
-	conn_cond_update_sock_polling(conn);
 	return done;
 }
 
@@ -310,7 +308,6 @@
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 
  leave:
-	conn_cond_update_sock_polling(conn);
 	return done;
 
  read0:
@@ -393,7 +390,6 @@
 	if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 
-	conn_cond_update_sock_polling(conn);
 	if (done > 0) {
 		/* we count the total bytes sent, and the send rate for 32-byte
 		 * blocks. The reason for the latter is that freq_ctr are
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index fed53d5..6829823 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -542,7 +542,6 @@
 void ssl_async_fd_handler(int fd)
 {
 	struct ssl_sock_ctx *ctx = fdtab[fd].owner;
-	struct connection *conn = ctx->conn;
 
 	/* fd is an async enfine fd, we must stop
 	 * to poll this fd until it is requested
@@ -553,9 +552,7 @@
 	/* crypto engine is available, let's notify the associated
 	 * connection that it can pursue its processing.
 	 */
-	__conn_sock_want_recv(conn);
-	__conn_sock_want_send(conn);
-	conn_update_sock_polling(conn);
+	ssl_sock_io_cb(NULL, ctx, 0);
 }
 
 /*
@@ -597,7 +594,6 @@
 	OSSL_ASYNC_FD add_fd[32];
 	OSSL_ASYNC_FD del_fd[32];
 	SSL *ssl = ctx->ssl;
-	struct connection *conn = ctx->conn;
 	size_t num_add_fds = 0;
 	size_t num_del_fds = 0;
 	int i;
@@ -640,11 +636,6 @@
 		fd_cant_recv(add_fd[i]);
 	}
 
-	/* We must also prevent the conn_handler
-	 * to be called until a read event was
-	 * polled on an async fd
-	 */
-	__conn_sock_stop_both(conn);
 }
 #endif
 
@@ -5331,10 +5322,8 @@
 
 			if (ret == SSL_ERROR_WANT_WRITE) {
 				/* SSL handshake needs to write, L4 connection may not be ready */
-				if (!(ctx->wait_event.events & SUB_RETRY_SEND)) {
-						__conn_sock_want_send(conn);
+				if (!(ctx->wait_event.events & SUB_RETRY_SEND))
 					ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
-				}
 				return 0;
 			}
 			else if (ret == SSL_ERROR_WANT_READ) {
@@ -5346,10 +5335,8 @@
 					goto reneg_ok;
 				}
 				/* SSL handshake needs to read, L4 connection is ready */
-				if (!(ctx->wait_event.events & SUB_RETRY_RECV)) {
-						__conn_sock_want_recv(conn);
+				if (!(ctx->wait_event.events & SUB_RETRY_RECV))
 					ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_RECV, &ctx->wait_event);
-				}
 				return 0;
 			}
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
@@ -5422,20 +5409,15 @@
 
 		if (ret == SSL_ERROR_WANT_WRITE) {
 			/* SSL handshake needs to write, L4 connection may not be ready */
-			if (!(ctx->wait_event.events & SUB_RETRY_SEND)) {
-				__conn_sock_want_send(conn);
+			if (!(ctx->wait_event.events & SUB_RETRY_SEND))
 				ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
-			}
 			return 0;
 		}
 		else if (ret == SSL_ERROR_WANT_READ) {
 			/* SSL handshake needs to read, L4 connection is ready */
 			if (!(ctx->wait_event.events & SUB_RETRY_RECV))
-			{
-				__conn_sock_want_recv(conn);
 				ctx->xprt->subscribe(conn, ctx->xprt_ctx,
 				    SUB_RETRY_RECV, &ctx->wait_event);
-			}
 			return 0;
 		}
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
@@ -5809,7 +5791,6 @@
 			if (ret == SSL_ERROR_WANT_WRITE) {
 				/* handshake is running, and it needs to enable write */
 				conn->flags |= CO_FL_SSL_WAIT_HS;
-				__conn_sock_want_send(conn);
 				ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
 				/* Async mode can be re-enabled, because we're leaving data state.*/
@@ -5825,7 +5806,6 @@
 							     &ctx->wait_event);
 					/* handshake is running, and it may need to re-enable read */
 					conn->flags |= CO_FL_SSL_WAIT_HS;
-					__conn_sock_want_recv(conn);
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
 					/* Async mode can be re-enabled, because we're leaving data state.*/
 					if (global_ssl.async)
@@ -5848,7 +5828,6 @@
 			break;
 	}
  leave:
-	conn_cond_update_sock_polling(conn);
 	return done;
 
  clear_ssl_error:
@@ -5973,7 +5952,6 @@
 				if (SSL_renegotiate_pending(ctx->ssl)) {
 					/* handshake is running, and it may need to re-enable write */
 					conn->flags |= CO_FL_SSL_WAIT_HS;
-					__conn_sock_want_send(conn);
 					ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
 					/* Async mode can be re-enabled, because we're leaving data state.*/
@@ -5988,7 +5966,6 @@
 			else if (ret == SSL_ERROR_WANT_READ) {
 				/* handshake is running, and it needs to enable read */
 				conn->flags |= CO_FL_SSL_WAIT_HS;
-				__conn_sock_want_recv(conn);
 				ctx->xprt->subscribe(conn, ctx->xprt_ctx,
 				                     SUB_RETRY_RECV,
 						     &ctx->wait_event);
@@ -6003,7 +5980,6 @@
 		}
 	}
  leave:
-	conn_cond_update_sock_polling(conn);
 	return done;
 
  out_error:
diff --git a/src/stream_interface.c b/src/stream_interface.c
index a6d5d02..bdc9b00 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -422,7 +422,6 @@
 	if (conn->flags & CO_FL_WAIT_L4_CONN)
 		conn->flags &= ~CO_FL_WAIT_L4_CONN;
 	conn->flags &= ~flag;
-	__conn_sock_stop_send(conn);
 	return 1;
 
  out_error:
@@ -431,8 +430,6 @@
 	return 0;
 
  out_wait:
-	__conn_sock_stop_recv(conn);
-	__conn_sock_want_send(conn);
 	return 0;
 }