MEDIUM: servers: Split the connections into idle, safe, and available.
Revamp the server connection lists. We know have 3 lists :
- idle_conns, which contains idling connections
- safe_conns, which contains idling connections that are safe to use even
for the first request
- available_conns, which contains connections that are not idling, but can
still accept new streams (those are HTTP/2 or fastcgi, and are always
considered safe).
diff --git a/include/proto/server.h b/include/proto/server.h
index 516be49..06f553e 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -245,7 +245,7 @@
/* This adds an idle connection to the server's list if the connection is
* reusable, not held by any owner anymore, but still has available streams.
*/
-static inline int srv_add_to_idle_list(struct server *srv, struct connection *conn)
+static inline int srv_add_to_idle_list(struct server *srv, struct connection *conn, int is_safe)
{
if (srv && srv->pool_purge_delay > 0 &&
(srv->max_idle_conns == -1 || srv->max_idle_conns > srv->curr_idle_conns) &&
@@ -262,7 +262,8 @@
return 0;
}
LIST_DEL_INIT(&conn->list);
- MT_LIST_ADDQ(&srv->idle_orphan_conns[tid], (struct mt_list *)&conn->list);
+ MT_LIST_ADDQ(is_safe ? &srv->safe_conns[tid] : &srv->idle_conns[tid],
+ (struct mt_list *)&conn->list);
srv->curr_idle_thr[tid]++;
conn->idle_time = now_ms;
diff --git a/include/types/server.h b/include/types/server.h
index 0257f58..c29fd18 100644
--- a/include/types/server.h
+++ b/include/types/server.h
@@ -222,9 +222,9 @@
struct eb_root pendconns; /* pending connections */
struct list actconns; /* active connections */
- struct list *idle_conns; /* sharable idle connections attached or not to a stream interface */
- struct list *safe_conns; /* safe idle connections attached to stream interfaces, shared */
- struct mt_list *idle_orphan_conns; /* Orphan connections idling */
+ struct mt_list *idle_conns; /* sharable idle connections*/
+ struct mt_list *safe_conns; /* safe idle connections */
+ struct list *available_conns; /* Connection in used, but with still new streams available */
unsigned int pool_purge_delay; /* Delay before starting to purge the idle conns pool */
unsigned int max_idle_conns; /* Max number of connection allowed in the orphan connections list */
unsigned int curr_idle_conns; /* Current number of orphan idling connections */