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/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;
}