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.
This commit is contained in:
Olivier Houchard 2019-05-28 10:12:02 +02:00 committed by Olivier Houchard
parent fe50bfb82c
commit 03abf2d31e
9 changed files with 19 additions and 262 deletions

View File

@ -158,14 +158,6 @@ static inline void conn_stop_tracking(struct connection *conn)
conn->flags &= ~CO_FL_XPRT_TRACKED; 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_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 /* 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 * 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_*. * in CO_FL_WAIT_*, and the upper layer expectations indicated by CO_FL_XPRT_*.
@ -216,51 +208,17 @@ static inline unsigned int conn_xprt_polling_changes(const struct connection *c)
return f & (CO_FL_CURR_WR_ENA | CO_FL_CURR_RD_ENA | CO_FL_ERROR); 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 /* Automatically updates polling on connection <c> depending on the XPRT flags.
* or if the WAIT flags are set with their respective ENA flags. Additionally, * It does nothing if CO_FL_WILL_UPDATE is present, indicating that an upper
* non-zero is also returned if an error was reported on the connection. This * caller is going to do it again later.
* 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.
*/ */
static inline void conn_cond_update_xprt_polling(struct connection *c) static inline void conn_cond_update_xprt_polling(struct connection *c)
{ {
if (!(c->flags & CO_FL_WILL_UPDATE)) 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); 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 /* 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 * 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 * CO_FL_WILL_UPDATE is present, indicating that an upper caller is going to do
@ -269,7 +227,6 @@ static inline void conn_cond_update_sock_polling(struct connection *c)
static inline void conn_stop_polling(struct connection *c) static inline void conn_stop_polling(struct connection *c)
{ {
c->flags &= ~(CO_FL_CURR_RD_ENA | CO_FL_CURR_WR_ENA | 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); CO_FL_XPRT_RD_ENA | CO_FL_XPRT_WR_ENA);
if (!(c->flags & CO_FL_WILL_UPDATE) && conn_ctrl_ready(c)) if (!(c->flags & CO_FL_WILL_UPDATE) && conn_ctrl_ready(c))
fd_stop_both(c->handle.fd); fd_stop_both(c->handle.fd);
@ -287,10 +244,8 @@ static inline void conn_cond_update_polling(struct connection *c)
if (unlikely(c->flags & CO_FL_ERROR)) if (unlikely(c->flags & CO_FL_ERROR))
conn_stop_polling(c); conn_stop_polling(c);
else if (!(c->flags & CO_FL_WILL_UPDATE)) { 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); 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 @@ static inline void conn_xprt_stop_both(struct connection *c)
conn_cond_update_xprt_polling(c); 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 /* read shutdown, called from the rcv_buf/rcv_pipe handlers when
* detecting an end of connection. * detecting an end of connection.
*/ */
static inline void conn_sock_read0(struct connection *c) static inline void conn_sock_read0(struct connection *c)
{ {
c->flags |= CO_FL_SOCK_RD_SH; 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 /* we don't risk keeping ports unusable if we found the
* zero from the other side. * zero from the other side.
*/ */
@ -451,8 +346,8 @@ static inline void conn_sock_shutw(struct connection *c, int clean)
{ {
c->flags |= CO_FL_SOCK_WR_SH; c->flags |= CO_FL_SOCK_WR_SH;
conn_refresh_polling_flags(c); conn_refresh_polling_flags(c);
__conn_sock_stop_send(c); __conn_xprt_stop_send(c);
conn_cond_update_sock_polling(c); conn_cond_update_xprt_polling(c);
/* don't perform a clean shutdown if we're going to reset or /* don't perform a clean shutdown if we're going to reset or
* if the shutr was already received. * if the shutr was already received.

View File

@ -136,12 +136,12 @@ enum {
CO_FL_NONE = 0x00000000, /* Just for initialization purposes */ CO_FL_NONE = 0x00000000, /* Just for initialization purposes */
/* Do not change these values without updating conn_*_poll_changes() ! */ /* 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_XPRT_RD_ENA = 0x00000002, /* receiving data is allowed */
CO_FL_CURR_RD_ENA = 0x00000004, /* receiving is currently allowed */ CO_FL_CURR_RD_ENA = 0x00000004, /* receiving is currently allowed */
/* unused : 0x00000008 */ /* 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_XPRT_WR_ENA = 0x00000020, /* sending data is desired */
CO_FL_CURR_WR_ENA = 0x00000040, /* sending is currently desired */ CO_FL_CURR_WR_ENA = 0x00000040, /* sending is currently desired */
/* unused : 0x00000080 */ /* unused : 0x00000080 */
@ -194,13 +194,6 @@ enum {
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 = 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, 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 */ /* This connection may not be shared between clients */
CO_FL_PRIVATE = 0x10000000, CO_FL_PRIVATE = 0x10000000,

View File

@ -58,15 +58,6 @@ void conn_fd_handler(int fd)
flags = conn->flags & ~CO_FL_ERROR; /* ensure to call the wake handler upon error */ 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 /* The connection owner might want to be notified about an end of
* handshake indicating the connection is ready, before we proceed with * handshake indicating the connection is ready, before we proceed with
* any data exchange. The callback may fail and cause the connection to * any data exchange. The callback may fail and cause the connection to
@ -197,41 +188,6 @@ void conn_update_xprt_polling(struct connection *c)
c->flags = f; 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 /* 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 * 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 * then -1 is returned and ENOTSOCK is set into errno. If the fd is not marked
@ -704,12 +660,9 @@ int conn_recv_proxy(struct connection *conn, int flag)
conn->flags &= ~flag; conn->flags &= ~flag;
conn->flags |= CO_FL_RCVD_PROXY; conn->flags |= CO_FL_RCVD_PROXY;
__conn_sock_stop_recv(conn);
return 1; return 1;
not_ready: not_ready:
__conn_sock_want_recv(conn);
__conn_sock_stop_send(conn);
return 0; return 0;
missing: missing:
@ -731,7 +684,6 @@ int conn_recv_proxy(struct connection *conn, int flag)
goto fail; goto fail;
fail: fail:
__conn_sock_stop_both(conn);
conn->flags |= CO_FL_ERROR; conn->flags |= CO_FL_ERROR;
return 0; return 0;
} }
@ -908,12 +860,9 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
} while (0); } while (0);
conn->flags &= ~flag; conn->flags &= ~flag;
__conn_sock_stop_recv(conn);
return 1; return 1;
not_ready: not_ready:
__conn_sock_want_recv(conn);
__conn_sock_stop_send(conn);
return 0; return 0;
missing: missing:
@ -934,7 +883,6 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
goto fail; goto fail;
fail: fail:
__conn_sock_stop_both(conn);
conn->flags |= CO_FL_ERROR; conn->flags |= CO_FL_ERROR;
return 0; return 0;
} }
@ -991,7 +939,6 @@ int conn_send_socks4_proxy_request(struct connection *conn)
/* OK we've the whole request sent */ /* OK we've the whole request sent */
conn->flags &= ~CO_FL_SOCKS4_SEND; conn->flags &= ~CO_FL_SOCKS4_SEND;
__conn_sock_stop_send(conn);
/* The connection is ready now, simply return and let the connection /* The connection is ready now, simply return and let the connection
* handler notify upper layers if needed. * handler notify upper layers if needed.
@ -1018,8 +965,6 @@ int conn_send_socks4_proxy_request(struct connection *conn)
return 0; return 0;
out_wait: out_wait:
__conn_sock_stop_recv(conn);
__conn_sock_want_send(conn);
return 0; return 0;
} }
@ -1125,12 +1070,9 @@ int conn_recv_socks4_proxy_response(struct connection *conn)
} while (0); } while (0);
conn->flags &= ~CO_FL_SOCKS4_RECV; conn->flags &= ~CO_FL_SOCKS4_RECV;
__conn_sock_stop_recv(conn);
return 1; return 1;
not_ready: not_ready:
__conn_sock_want_recv(conn);
__conn_sock_stop_send(conn);
return 0; return 0;
recv_abort: recv_abort:
@ -1141,7 +1083,6 @@ int conn_recv_socks4_proxy_response(struct connection *conn)
goto fail; goto fail;
fail: fail:
__conn_sock_stop_both(conn);
conn->flags |= CO_FL_ERROR; conn->flags |= CO_FL_ERROR;
return 0; return 0;
} }

View File

@ -327,20 +327,7 @@ static int sockpair_connect_server(struct connection *conn, int flags)
return SF_ERR_RESOURCE; return SF_ERR_RESOURCE;
} }
if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN)) { conn_xprt_want_send(conn); /* for connect status, proxy protocol or SSL */
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 */
return SF_ERR_NONE; /* connection is OK */ return SF_ERR_NONE; /* connection is OK */
} }

View File

@ -578,22 +578,7 @@ int tcp_connect_server(struct connection *conn, int flags)
return SF_ERR_RESOURCE; return SF_ERR_RESOURCE;
} }
if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN | CO_FL_EARLY_SSL_HS)) { conn_xprt_want_send(conn); /* for connect status, proxy protocol or SSL */
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 */
return SF_ERR_NONE; /* connection is OK */ return SF_ERR_NONE; /* connection is OK */
} }
@ -706,7 +691,7 @@ int tcp_connect_probe(struct connection *conn)
if (connect(fd, (const struct sockaddr *)addr, get_addr_len(addr)) == -1) { if (connect(fd, (const struct sockaddr *)addr, get_addr_len(addr)) == -1) {
if (errno == EALREADY || errno == EINPROGRESS) { if (errno == EALREADY || errno == EINPROGRESS) {
__conn_sock_stop_recv(conn); __conn_xprt_stop_recv(conn);
fd_cant_send(fd); fd_cant_send(fd);
return 0; return 0;
} }
@ -730,7 +715,7 @@ int tcp_connect_probe(struct connection *conn)
*/ */
fdtab[fd].linger_risk = 0; fdtab[fd].linger_risk = 0;
conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; 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; return 0;
} }

View File

@ -578,20 +578,7 @@ static int uxst_connect_server(struct connection *conn, int flags)
return SF_ERR_RESOURCE; return SF_ERR_RESOURCE;
} }
if (conn->flags & (CO_FL_HANDSHAKE | CO_FL_WAIT_L4_CONN)) { conn_xprt_want_send(conn); /* for connect status, proxy protocol or SSL */
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 */
return SF_ERR_NONE; /* connection is OK */ return SF_ERR_NONE; /* connection is OK */
} }

View File

@ -157,7 +157,6 @@ int raw_sock_to_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pipe,
conn->flags &= ~CO_FL_WAIT_L4_CONN; conn->flags &= ~CO_FL_WAIT_L4_CONN;
leave: leave:
conn_cond_update_sock_polling(conn);
if (retval > 0) { if (retval > 0) {
/* we count the total bytes sent, and the send rate for 32-byte /* we count the total bytes sent, and the send rate for 32-byte
* blocks. The reason for the latter is that freq_ctr are * blocks. The reason for the latter is that freq_ctr are
@ -211,7 +210,6 @@ int raw_sock_from_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pip
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done) if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN; conn->flags &= ~CO_FL_WAIT_L4_CONN;
conn_cond_update_sock_polling(conn);
return done; return done;
} }
@ -310,7 +308,6 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu
conn->flags &= ~CO_FL_WAIT_L4_CONN; conn->flags &= ~CO_FL_WAIT_L4_CONN;
leave: leave:
conn_cond_update_sock_polling(conn);
return done; return done;
read0: read0:
@ -393,7 +390,6 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done) if (unlikely(conn->flags & CO_FL_WAIT_L4_CONN) && done)
conn->flags &= ~CO_FL_WAIT_L4_CONN; conn->flags &= ~CO_FL_WAIT_L4_CONN;
conn_cond_update_sock_polling(conn);
if (done > 0) { if (done > 0) {
/* we count the total bytes sent, and the send rate for 32-byte /* we count the total bytes sent, and the send rate for 32-byte
* blocks. The reason for the latter is that freq_ctr are * blocks. The reason for the latter is that freq_ctr are

View File

@ -542,7 +542,6 @@ fail_get:
void ssl_async_fd_handler(int fd) void ssl_async_fd_handler(int fd)
{ {
struct ssl_sock_ctx *ctx = fdtab[fd].owner; struct ssl_sock_ctx *ctx = fdtab[fd].owner;
struct connection *conn = ctx->conn;
/* fd is an async enfine fd, we must stop /* fd is an async enfine fd, we must stop
* to poll this fd until it is requested * to poll this fd until it is requested
@ -553,9 +552,7 @@ void ssl_async_fd_handler(int fd)
/* crypto engine is available, let's notify the associated /* crypto engine is available, let's notify the associated
* connection that it can pursue its processing. * connection that it can pursue its processing.
*/ */
__conn_sock_want_recv(conn); ssl_sock_io_cb(NULL, ctx, 0);
__conn_sock_want_send(conn);
conn_update_sock_polling(conn);
} }
/* /*
@ -597,7 +594,6 @@ static inline void ssl_async_process_fds(struct ssl_sock_ctx *ctx)
OSSL_ASYNC_FD add_fd[32]; OSSL_ASYNC_FD add_fd[32];
OSSL_ASYNC_FD del_fd[32]; OSSL_ASYNC_FD del_fd[32];
SSL *ssl = ctx->ssl; SSL *ssl = ctx->ssl;
struct connection *conn = ctx->conn;
size_t num_add_fds = 0; size_t num_add_fds = 0;
size_t num_del_fds = 0; size_t num_del_fds = 0;
int i; int i;
@ -640,11 +636,6 @@ static inline void ssl_async_process_fds(struct ssl_sock_ctx *ctx)
fd_cant_recv(add_fd[i]); 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 #endif
@ -5331,10 +5322,8 @@ static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
if (ret == SSL_ERROR_WANT_WRITE) { if (ret == SSL_ERROR_WANT_WRITE) {
/* SSL handshake needs to write, L4 connection may not be ready */ /* SSL handshake needs to write, L4 connection may not be ready */
if (!(ctx->wait_event.events & SUB_RETRY_SEND)) { if (!(ctx->wait_event.events & SUB_RETRY_SEND))
__conn_sock_want_send(conn);
ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event); ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
}
return 0; return 0;
} }
else if (ret == SSL_ERROR_WANT_READ) { else if (ret == SSL_ERROR_WANT_READ) {
@ -5346,10 +5335,8 @@ static int ssl_sock_handshake(struct connection *conn, unsigned int flag)
goto reneg_ok; goto reneg_ok;
} }
/* SSL handshake needs to read, L4 connection is ready */ /* SSL handshake needs to read, L4 connection is ready */
if (!(ctx->wait_event.events & SUB_RETRY_RECV)) { 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); ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_RECV, &ctx->wait_event);
}
return 0; return 0;
} }
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
@ -5422,20 +5409,15 @@ check_error:
if (ret == SSL_ERROR_WANT_WRITE) { if (ret == SSL_ERROR_WANT_WRITE) {
/* SSL handshake needs to write, L4 connection may not be ready */ /* SSL handshake needs to write, L4 connection may not be ready */
if (!(ctx->wait_event.events & SUB_RETRY_SEND)) { if (!(ctx->wait_event.events & SUB_RETRY_SEND))
__conn_sock_want_send(conn);
ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event); ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
}
return 0; return 0;
} }
else if (ret == SSL_ERROR_WANT_READ) { else if (ret == SSL_ERROR_WANT_READ) {
/* SSL handshake needs to read, L4 connection is ready */ /* SSL handshake needs to read, L4 connection is ready */
if (!(ctx->wait_event.events & SUB_RETRY_RECV)) if (!(ctx->wait_event.events & SUB_RETRY_RECV))
{
__conn_sock_want_recv(conn);
ctx->xprt->subscribe(conn, ctx->xprt_ctx, ctx->xprt->subscribe(conn, ctx->xprt_ctx,
SUB_RETRY_RECV, &ctx->wait_event); SUB_RETRY_RECV, &ctx->wait_event);
}
return 0; return 0;
} }
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
@ -5809,7 +5791,6 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu
if (ret == SSL_ERROR_WANT_WRITE) { if (ret == SSL_ERROR_WANT_WRITE) {
/* handshake is running, and it needs to enable write */ /* handshake is running, and it needs to enable write */
conn->flags |= CO_FL_SSL_WAIT_HS; 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); ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
/* Async mode can be re-enabled, because we're leaving data state.*/ /* Async mode can be re-enabled, because we're leaving data state.*/
@ -5825,7 +5806,6 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu
&ctx->wait_event); &ctx->wait_event);
/* handshake is running, and it may need to re-enable read */ /* handshake is running, and it may need to re-enable read */
conn->flags |= CO_FL_SSL_WAIT_HS; conn->flags |= CO_FL_SSL_WAIT_HS;
__conn_sock_want_recv(conn);
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
/* Async mode can be re-enabled, because we're leaving data state.*/ /* Async mode can be re-enabled, because we're leaving data state.*/
if (global_ssl.async) if (global_ssl.async)
@ -5848,7 +5828,6 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu
break; break;
} }
leave: leave:
conn_cond_update_sock_polling(conn);
return done; return done;
clear_ssl_error: clear_ssl_error:
@ -5973,7 +5952,6 @@ static size_t ssl_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
if (SSL_renegotiate_pending(ctx->ssl)) { if (SSL_renegotiate_pending(ctx->ssl)) {
/* handshake is running, and it may need to re-enable write */ /* handshake is running, and it may need to re-enable write */
conn->flags |= CO_FL_SSL_WAIT_HS; 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); ctx->xprt->subscribe(conn, ctx->xprt_ctx, SUB_RETRY_SEND, &ctx->wait_event);
#if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC) #if (HA_OPENSSL_VERSION_NUMBER >= 0x1010000fL) && !defined(OPENSSL_NO_ASYNC)
/* Async mode can be re-enabled, because we're leaving data state.*/ /* Async mode can be re-enabled, because we're leaving data state.*/
@ -5988,7 +5966,6 @@ static size_t ssl_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
else if (ret == SSL_ERROR_WANT_READ) { else if (ret == SSL_ERROR_WANT_READ) {
/* handshake is running, and it needs to enable read */ /* handshake is running, and it needs to enable read */
conn->flags |= CO_FL_SSL_WAIT_HS; conn->flags |= CO_FL_SSL_WAIT_HS;
__conn_sock_want_recv(conn);
ctx->xprt->subscribe(conn, ctx->xprt_ctx, ctx->xprt->subscribe(conn, ctx->xprt_ctx,
SUB_RETRY_RECV, SUB_RETRY_RECV,
&ctx->wait_event); &ctx->wait_event);
@ -6003,7 +5980,6 @@ static size_t ssl_sock_from_buf(struct connection *conn, void *xprt_ctx, const s
} }
} }
leave: leave:
conn_cond_update_sock_polling(conn);
return done; return done;
out_error: out_error:

View File

@ -422,7 +422,6 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
if (conn->flags & CO_FL_WAIT_L4_CONN) if (conn->flags & CO_FL_WAIT_L4_CONN)
conn->flags &= ~CO_FL_WAIT_L4_CONN; conn->flags &= ~CO_FL_WAIT_L4_CONN;
conn->flags &= ~flag; conn->flags &= ~flag;
__conn_sock_stop_send(conn);
return 1; return 1;
out_error: out_error:
@ -431,8 +430,6 @@ int conn_si_send_proxy(struct connection *conn, unsigned int flag)
return 0; return 0;
out_wait: out_wait:
__conn_sock_stop_recv(conn);
__conn_sock_want_send(conn);
return 0; return 0;
} }