BUG/MEDIUM: mux-fcgi: Don't add private connections in available connection list

When a stream is detached from a backend private connection, we must not insert
it in the available connection list. In addition, we must be sure to remove it
from this list. To ensure it is properly performed, this part has been slightly
refactored to clearly split processing of private connections from the others.

This patch should probably be backported to 2.2.
This commit is contained in:
Christopher Faulet 2020-07-01 15:51:46 +02:00
parent c5579d18d1
commit 29ae7ffed9

View File

@ -3543,7 +3543,8 @@ static void fcgi_detach(struct conn_stream *cs)
/* Never ever allow to reuse a connection from a non-reuse backend */
if ((fconn->proxy->options & PR_O_REUSE_MASK) == PR_O_REUSE_NEVR)
fconn->conn->flags |= CO_FL_PRIVATE;
if (!fconn->conn->owner && (fconn->conn->flags & CO_FL_PRIVATE)) {
if (fconn->conn->flags & CO_FL_PRIVATE) {
if (!fconn->conn->owner) {
fconn->conn->owner = sess;
if (!session_add_conn(sess, fconn->conn, fconn->conn->target)) {
fconn->conn->owner = NULL;
@ -3555,14 +3556,20 @@ static void fcgi_detach(struct conn_stream *cs)
}
}
}
if (eb_is_empty(&fconn->streams_by_id)) {
if (sess && fconn->conn->owner == sess &&
session_check_idle_conn(fconn->conn->owner, fconn->conn) != 0) {
if (eb_is_empty(&fconn->streams_by_id) && fconn->conn->owner == sess) {
if (session_check_idle_conn(fconn->conn->owner, fconn->conn) != 0) {
/* The connection is destroyed, let's leave */
TRACE_DEVEL("outgoing connection killed", FCGI_EV_STRM_END|FCGI_EV_FCONN_ERR);
return;
}
if (!(fconn->conn->flags & CO_FL_PRIVATE)) {
}
/* Be sure to remove the connection from the available_conns list */
if (!MT_LIST_ISEMPTY(&fconn->conn->list))
MT_LIST_DEL(&fconn->conn->list);
}
else {
if (eb_is_empty(&fconn->streams_by_id)) {
if (!srv_add_to_idle_list(objt_server(fconn->conn->target), fconn->conn, 1)) {
/* The server doesn't want it, let's kill the connection right away */
fconn->conn->mux->destroy(fconn);
@ -3576,11 +3583,11 @@ static void fcgi_detach(struct conn_stream *cs)
TRACE_DEVEL("reusable idle connection", FCGI_EV_STRM_END, fconn->conn);
return;
}
} else if (MT_LIST_ISEMPTY(&fconn->conn->list) &&
else if (MT_LIST_ISEMPTY(&fconn->conn->list) &&
fcgi_avail_streams(fconn->conn) > 0 && objt_server(fconn->conn->target)) {
LIST_ADD(&__objt_server(fconn->conn->target)->available_conns[tid], mt_list_to_list(&fconn->conn->list));
}
}
}
/* We don't want to close right now unless we're removing the last