mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MEDIUM: backend: never reuse a connection for tcp mode
The reuse of idle connections should only happen for a proxy with the http mode. In case of a backend with the tcp mode, the reuse selection and insertion in session list are skipped. This behavior is present since commit : MEDIUM: connection: Add private connections synchronously in session server list It could also be further exagerated by : MEDIUM: backend: add reused conn to sess if mux marked as HOL blocking It can be backported up to 2.3.
This commit is contained in:
parent
3f07c20fab
commit
08d87b3f49
@ -1248,13 +1248,16 @@ int connect_server(struct stream *s)
|
|||||||
*/
|
*/
|
||||||
si_release_endpoint(&s->si[1]);
|
si_release_endpoint(&s->si[1]);
|
||||||
|
|
||||||
|
srv = objt_server(s->target);
|
||||||
|
|
||||||
|
if (s->be->mode != PR_MODE_HTTP)
|
||||||
|
goto skip_reuse;
|
||||||
|
|
||||||
/* first, search for a matching connection in the session's idle conns */
|
/* first, search for a matching connection in the session's idle conns */
|
||||||
srv_conn = session_get_conn(s->sess, s->target);
|
srv_conn = session_get_conn(s->sess, s->target);
|
||||||
if (srv_conn)
|
if (srv_conn)
|
||||||
reuse = 1;
|
reuse = 1;
|
||||||
|
|
||||||
srv = objt_server(s->target);
|
|
||||||
|
|
||||||
if (srv && !reuse && reuse_mode != PR_O_REUSE_NEVR) {
|
if (srv && !reuse && reuse_mode != PR_O_REUSE_NEVR) {
|
||||||
/* Below we pick connections from the safe, idle or
|
/* Below we pick connections from the safe, idle or
|
||||||
* available (which are safe too) lists based
|
* available (which are safe too) lists based
|
||||||
@ -1391,6 +1394,7 @@ int connect_server(struct stream *s)
|
|||||||
else
|
else
|
||||||
srv_conn = NULL;
|
srv_conn = NULL;
|
||||||
|
|
||||||
|
skip_reuse:
|
||||||
/* no reuse or failed to reuse the connection above, pick a new one */
|
/* no reuse or failed to reuse the connection above, pick a new one */
|
||||||
if (!srv_conn) {
|
if (!srv_conn) {
|
||||||
srv_conn = conn_new(s->target);
|
srv_conn = conn_new(s->target);
|
||||||
@ -1541,21 +1545,26 @@ int connect_server(struct stream *s)
|
|||||||
conn_full_close(srv_conn);
|
conn_full_close(srv_conn);
|
||||||
return SF_ERR_INTERNAL;
|
return SF_ERR_INTERNAL;
|
||||||
}
|
}
|
||||||
/* If we're doing http-reuse always, and the connection is not
|
if (s->be->mode != PR_MODE_HTTP) {
|
||||||
* private with available streams (an http2 connection), add it
|
/* If we're doing http-reuse always, and the connection
|
||||||
* to the available list, so that others can use it right
|
* is not private with available streams (an http2
|
||||||
* away. If the connection is private or we're doing http-reuse
|
* connection), add it to the available list, so that
|
||||||
* safe and the mux protocol supports multiplexing, add it in
|
* others can use it right away. If the connection is
|
||||||
* the session server list.
|
* private or we're doing http-reuse safe and the mux
|
||||||
*/
|
* protocol supports multiplexing, add it in the
|
||||||
if (srv && reuse_mode == PR_O_REUSE_ALWS &&
|
* session server list.
|
||||||
!(srv_conn->flags & CO_FL_PRIVATE) && srv_conn->mux->avail_streams(srv_conn) > 0)
|
*/
|
||||||
LIST_ADDQ(&srv->available_conns[tid], mt_list_to_list(&srv_conn->list));
|
if (srv && reuse_mode == PR_O_REUSE_ALWS &&
|
||||||
else if (srv_conn->flags & CO_FL_PRIVATE ||
|
!(srv_conn->flags & CO_FL_PRIVATE) &&
|
||||||
(reuse_mode == PR_O_REUSE_SAFE &&
|
srv_conn->mux->avail_streams(srv_conn) > 0) {
|
||||||
srv_conn->mux->flags & MX_FL_HOL_RISK)) {
|
LIST_ADDQ(&srv->available_conns[tid], mt_list_to_list(&srv_conn->list));
|
||||||
/* If it fail now, the same will be done in mux->detach() callback */
|
}
|
||||||
session_add_conn(s->sess, srv_conn, srv_conn->target);
|
else if (srv_conn->flags & CO_FL_PRIVATE ||
|
||||||
|
(reuse_mode == PR_O_REUSE_SAFE &&
|
||||||
|
srv_conn->mux->flags & MX_FL_HOL_RISK)) {
|
||||||
|
/* If it fail now, the same will be done in mux->detach() callback */
|
||||||
|
session_add_conn(s->sess, srv_conn, srv_conn->target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user