void _srv_add_idle(struct server *srv, struct connection *conn, int is_safe);
int srv_add_to_idle_list(struct server *srv, struct connection *conn, int is_safe);
+void srv_add_to_avail_list(struct server *srv, struct connection *conn);
struct task *srv_cleanup_toremove_conns(struct task *task, void *context, unsigned int state);
int srv_apply_track(struct server *srv, struct proxy *curproxy);
session_add_conn(s->sess, conn, conn->target);
}
else {
- eb64_insert(&srv->per_thr[tid].avail_conns,
- &conn->hash_node->node);
+ srv_add_to_avail_list(srv, conn);
}
}
return conn;
if (srv && reuse_mode == PR_O_REUSE_ALWS &&
!(srv_conn->flags & CO_FL_PRIVATE) &&
srv_conn->mux->avail_streams(srv_conn) > 0) {
- eb64_insert(&srv->per_thr[tid].avail_conns, &srv_conn->hash_node->node);
+ srv_add_to_avail_list(srv, srv_conn);
}
else if (srv_conn->flags & CO_FL_PRIVATE ||
(reuse_mode == PR_O_REUSE_SAFE &&
#include <haproxy/proto_tcp.h>
#include <haproxy/sample.h>
#include <haproxy/sc_strm.h>
+#include <haproxy/server.h>
#include <haproxy/session.h>
#include <haproxy/ssl_sock.h>
#include <haproxy/stconn.h>
* server list.
*/
if (srv && ((srv->proxy->options & PR_O_REUSE_MASK) == PR_O_REUSE_ALWS) &&
- !(conn->flags & CO_FL_PRIVATE) && conn->mux->avail_streams(conn) > 0)
- eb64_insert(&srv->per_thr[tid].avail_conns, &conn->hash_node->node);
+ !(conn->flags & CO_FL_PRIVATE) && conn->mux->avail_streams(conn) > 0) {
+ srv_add_to_avail_list(srv, conn);
+ }
else if (conn->flags & CO_FL_PRIVATE) {
/* If it fail now, the same will be done in mux->detach() callback */
session_add_conn(sess, conn, conn->target);
#include <haproxy/proxy.h>
#include <haproxy/regex.h>
#include <haproxy/sc_strm.h>
+#include <haproxy/server.h>
#include <haproxy/session-t.h>
#include <haproxy/stconn.h>
#include <haproxy/stream.h>
else if (!fconn->conn->hash_node->node.node.leaf_p &&
fcgi_avail_streams(fconn->conn) > 0 && objt_server(fconn->conn->target) &&
!LIST_INLIST(&fconn->conn->session_list)) {
- eb64_insert(&__objt_server(fconn->conn->target)->per_thr[tid].avail_conns,
- &fconn->conn->hash_node->node);
+ srv_add_to_avail_list(__objt_server(fconn->conn->target), fconn->conn);
}
}
}
#include <haproxy/mux_h2-t.h>
#include <haproxy/net_helper.h>
#include <haproxy/proxy.h>
+#include <haproxy/server.h>
#include <haproxy/session-t.h>
#include <haproxy/stats.h>
#include <haproxy/stconn.h>
else if (!h2c->conn->hash_node->node.node.leaf_p &&
h2_avail_streams(h2c->conn) > 0 && objt_server(h2c->conn->target) &&
!LIST_INLIST(&h2c->conn->session_list)) {
- eb64_insert(&__objt_server(h2c->conn->target)->per_thr[tid].avail_conns,
- &h2c->conn->hash_node->node);
+ srv_add_to_avail_list(__objt_server(h2c->conn->target), h2c->conn);
}
}
}
return 0;
}
+/* Insert <conn> connection in <srv> server available list. This is reserved
+ * for backend connection currently in used with usable streams left.
+ */
+void srv_add_to_avail_list(struct server *srv, struct connection *conn)
+{
+ /* connection cannot be in idle list if used as an avail idle conn. */
+ BUG_ON(LIST_INLIST(&conn->idle_list));
+ eb64_insert(&srv->per_thr[tid].avail_conns, &conn->hash_node->node);
+}
+
struct task *srv_cleanup_idle_conns(struct task *task, void *context, unsigned int state)
{
struct server *srv;