MEDIUM: connection: replace idle conn lists by eb trees
The server idle/safe/available connection lists are replaced with ebmb-
trees. This is used to store backend connections, with the new field
connection hash as the key. The hash is a 8-bytes size field, used to
reflect specific connection parameters.
This is a preliminary work to be able to reuse connection with SNI,
explicit src/dst address or PROXY protocol.
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 093ab16..c946159 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -3803,7 +3803,7 @@
* to use it while we handle the I/O events
*/
if (conn_in_list)
- MT_LIST_DEL(&conn->list);
+ conn_delete_from_tree(&conn->hash_node);
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
@@ -3824,9 +3824,9 @@
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
if (conn_in_list == CO_FL_SAFE_LIST)
- MT_LIST_ADDQ(&srv->safe_conns[tid], &conn->list);
+ ebmb_insert(&srv->safe_conns_tree[tid], &conn->hash_node, sizeof(conn->hash));
else
- MT_LIST_ADDQ(&srv->idle_conns[tid], &conn->list);
+ ebmb_insert(&srv->idle_conns_tree[tid], &conn->hash_node, sizeof(conn->hash));
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
}
@@ -3905,13 +3905,13 @@
/* connections in error must be removed from the idle lists */
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
- MT_LIST_DEL((struct mt_list *)&conn->list);
+ conn_delete_from_tree(&conn->hash_node);
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
}
else if (h2c->st0 == H2_CS_ERROR) {
/* connections in error must be removed from the idle lists */
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
- MT_LIST_DEL((struct mt_list *)&conn->list);
+ conn_delete_from_tree(&conn->hash_node);
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
}
@@ -3999,7 +3999,7 @@
* to steal it from us.
*/
if (h2c->conn->flags & CO_FL_LIST_MASK)
- MT_LIST_DEL(&h2c->conn->list);
+ conn_delete_from_tree(&h2c->conn->hash_node);
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
}
@@ -4050,7 +4050,7 @@
/* in any case this connection must not be considered idle anymore */
HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
- MT_LIST_DEL((struct mt_list *)&h2c->conn->list);
+ conn_delete_from_tree(&h2c->conn->hash_node);
HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[tid].idle_conns_lock);
/* either we can release everything now or it will be done later once
@@ -4247,10 +4247,12 @@
return;
}
- else if (MT_LIST_ISEMPTY(&h2c->conn->list) &&
+ else if (!h2c->conn->hash_node.node.leaf_p &&
h2_avail_streams(h2c->conn) > 0 && objt_server(h2c->conn->target) &&
!LIST_ADDED(&h2c->conn->session_list)) {
- LIST_ADD(&__objt_server(h2c->conn->target)->available_conns[tid], mt_list_to_list(&h2c->conn->list));
+ ebmb_insert(&__objt_server(h2c->conn->target)->available_conns_tree[tid],
+ &h2c->conn->hash_node,
+ sizeof(h2c->conn->hash));
}
}
}