mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
MINOR: connection: simplify removal of idle conns from their trees
Small change of API for conn_delete_from_tree(). Now the connection instance is taken as argument instead of its inner node. No functional change introduced with this commit. This simplifies slightly invocation of conn_delete_from_tree(). The most useful changes is that this function will be extended in the next patch to be able to remove the connection from its new idle list at the same time as in its idle tree.
This commit is contained in:
parent
f20f85f4d7
commit
77ac8eb4a6
@ -81,7 +81,7 @@ int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess
|
||||
const struct mux_ops *force_mux_ops);
|
||||
int conn_install_mux_chk(struct connection *conn, void *ctx, struct session *sess);
|
||||
|
||||
void conn_delete_from_tree(struct eb64_node *node);
|
||||
void conn_delete_from_tree(struct connection *conn);
|
||||
|
||||
void conn_init(struct connection *conn, void *target);
|
||||
struct connection *conn_new(void *target);
|
||||
|
||||
@ -1163,7 +1163,7 @@ static struct connection *conn_backend_get(struct stream *s, struct server *srv,
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn = srv_lookup_conn(is_safe ? &srv->per_thr[tid].safe_conns : &srv->per_thr[tid].idle_conns, hash);
|
||||
if (conn)
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
|
||||
/* If we failed to pick a connection from the idle list, let's try again with
|
||||
* the safe list.
|
||||
@ -1171,7 +1171,7 @@ static struct connection *conn_backend_get(struct stream *s, struct server *srv,
|
||||
if (!conn && !is_safe && srv->curr_safe_nb > 0) {
|
||||
conn = srv_lookup_conn(&srv->per_thr[tid].safe_conns, hash);
|
||||
if (conn) {
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
is_safe = 1;
|
||||
}
|
||||
}
|
||||
@ -1214,7 +1214,7 @@ static struct connection *conn_backend_get(struct stream *s, struct server *srv,
|
||||
conn = srv_lookup_conn(is_safe ? &srv->per_thr[i].safe_conns : &srv->per_thr[i].idle_conns, hash);
|
||||
while (conn) {
|
||||
if (conn->mux->takeover && conn->mux->takeover(conn, i) == 0) {
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
_HA_ATOMIC_INC(&activity[tid].fd_takeover);
|
||||
found = 1;
|
||||
break;
|
||||
@ -1227,7 +1227,7 @@ static struct connection *conn_backend_get(struct stream *s, struct server *srv,
|
||||
conn = srv_lookup_conn(&srv->per_thr[i].safe_conns, hash);
|
||||
while (conn) {
|
||||
if (conn->mux->takeover && conn->mux->takeover(conn, i) == 0) {
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
_HA_ATOMIC_INC(&activity[tid].fd_takeover);
|
||||
found = 1;
|
||||
is_safe = 1;
|
||||
@ -1504,7 +1504,7 @@ static int connect_server(struct stream *s)
|
||||
if (node) {
|
||||
conn_node = ebmb_entry(node, struct conn_hash_node, node);
|
||||
tokill_conn = conn_node->conn;
|
||||
ebmb_delete(node);
|
||||
conn_delete_from_tree(tokill_conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
|
||||
/* Release the idle lock before calling mux->destroy.
|
||||
@ -1535,7 +1535,7 @@ static int connect_server(struct stream *s)
|
||||
if (node) {
|
||||
conn_node = ebmb_entry(node, struct conn_hash_node, node);
|
||||
tokill_conn = conn_node->conn;
|
||||
ebmb_delete(node);
|
||||
conn_delete_from_tree(tokill_conn);
|
||||
}
|
||||
|
||||
if (!tokill_conn) {
|
||||
@ -1543,7 +1543,7 @@ static int connect_server(struct stream *s)
|
||||
if (node) {
|
||||
conn_node = ebmb_entry(node, struct conn_hash_node, node);
|
||||
tokill_conn = conn_node->conn;
|
||||
ebmb_delete(node);
|
||||
conn_delete_from_tree(tokill_conn);
|
||||
}
|
||||
}
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
|
||||
@ -1568,7 +1568,7 @@ static int connect_server(struct stream *s)
|
||||
if (avail <= 1) {
|
||||
/* No more streams available, remove it from the list */
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&srv_conn->hash_node->node);
|
||||
conn_delete_from_tree(srv_conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -52,9 +52,9 @@ struct mux_stopping_data mux_stopping_data[MAX_THREADS];
|
||||
/* disables sending of proxy-protocol-v2's LOCAL command */
|
||||
static int pp2_never_send_local;
|
||||
|
||||
void conn_delete_from_tree(struct eb64_node *node)
|
||||
void conn_delete_from_tree(struct connection *conn)
|
||||
{
|
||||
eb64_delete(node);
|
||||
eb64_delete(&conn->hash_node->node);
|
||||
}
|
||||
|
||||
int conn_create_mux(struct connection *conn)
|
||||
@ -168,7 +168,7 @@ int conn_notify_mux(struct connection *conn, int old_flags, int forced_wake)
|
||||
|
||||
if (conn_in_list) {
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -2957,7 +2957,7 @@ struct task *fcgi_io_cb(struct task *t, void *ctx, unsigned int state)
|
||||
|
||||
conn_in_list = conn_get_idle_flag(conn);
|
||||
if (conn_in_list)
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
} else {
|
||||
@ -3139,7 +3139,7 @@ struct task *fcgi_timeout_task(struct task *t, void *context, unsigned int state
|
||||
* to steal it from us.
|
||||
*/
|
||||
if (fconn->conn->flags & CO_FL_LIST_MASK)
|
||||
conn_delete_from_tree(&fconn->conn->hash_node->node);
|
||||
conn_delete_from_tree(fconn->conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
|
||||
@ -3672,7 +3672,7 @@ struct task *h1_io_cb(struct task *t, void *ctx, unsigned int state)
|
||||
*/
|
||||
conn_in_list = conn_get_idle_flag(conn);
|
||||
if (conn_in_list)
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
} else {
|
||||
@ -3794,7 +3794,7 @@ struct task *h1_timeout_task(struct task *t, void *context, unsigned int state)
|
||||
* to steal it from us.
|
||||
*/
|
||||
if (h1c->conn->flags & CO_FL_LIST_MASK)
|
||||
conn_delete_from_tree(&h1c->conn->hash_node->node);
|
||||
conn_delete_from_tree(h1c->conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
|
||||
10
src/mux_h2.c
10
src/mux_h2.c
@ -4094,7 +4094,7 @@ struct task *h2_io_cb(struct task *t, void *ctx, unsigned int state)
|
||||
*/
|
||||
conn_in_list = conn_get_idle_flag(conn);
|
||||
if (conn_in_list)
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
} else {
|
||||
@ -4223,7 +4223,7 @@ static int h2_process(struct h2c *h2c)
|
||||
/* connections in error must be removed from the idle lists */
|
||||
if (conn->flags & CO_FL_LIST_MASK) {
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
}
|
||||
@ -4231,7 +4231,7 @@ static int h2_process(struct h2c *h2c)
|
||||
/* connections in error must be removed from the idle lists */
|
||||
if (conn->flags & CO_FL_LIST_MASK) {
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
}
|
||||
@ -4323,7 +4323,7 @@ struct task *h2_timeout_task(struct task *t, void *context, unsigned int state)
|
||||
* to steal it from us.
|
||||
*/
|
||||
if (h2c->conn->flags & CO_FL_LIST_MASK)
|
||||
conn_delete_from_tree(&h2c->conn->hash_node->node);
|
||||
conn_delete_from_tree(h2c->conn);
|
||||
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
@ -4375,7 +4375,7 @@ do_leave:
|
||||
/* in any case this connection must not be considered idle anymore */
|
||||
if (h2c->conn->flags & CO_FL_LIST_MASK) {
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&h2c->conn->hash_node->node);
|
||||
conn_delete_from_tree(h2c->conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -5944,7 +5944,7 @@ void srv_release_conn(struct server *srv, struct connection *conn)
|
||||
/* Remove the connection from any tree (safe, idle or available) */
|
||||
if (conn->hash_node) {
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
conn->flags &= ~CO_FL_LIST_MASK;
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
}
|
||||
@ -6018,7 +6018,7 @@ int srv_add_to_idle_list(struct server *srv, struct connection *conn, int is_saf
|
||||
_HA_ATOMIC_DEC(&srv->curr_used_conns);
|
||||
|
||||
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
|
||||
if (is_safe) {
|
||||
conn->flags = (conn->flags & ~CO_FL_LIST_MASK) | CO_FL_SAFE_LIST;
|
||||
|
||||
@ -6285,7 +6285,7 @@ struct task *ssl_sock_io_cb(struct task *t, void *context, unsigned int state)
|
||||
conn = ctx->conn;
|
||||
conn_in_list = conn_get_idle_flag(conn);
|
||||
if (conn_in_list)
|
||||
conn_delete_from_tree(&conn->hash_node->node);
|
||||
conn_delete_from_tree(conn);
|
||||
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
|
||||
} else {
|
||||
conn = ctx->conn;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user