From: Amaury Denoyelle Date: Thu, 28 Jan 2021 16:33:26 +0000 (+0100) Subject: BUG/MINOR: backend: check available list allocation for reuse X-Git-Tag: v2.4-dev7~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a81bb7197eb538628274bffe3b09e87e564aeb89;p=thirdparty%2Fhaproxy.git BUG/MINOR: backend: check available list allocation for reuse Do not consider reuse connection if available list is not allocated for the target server. This will prevent a crash when using a standalone server for an external purpose like socket_tcp/socket_ssl on hlua code. For the idle/safe lists, they are considered allocated if srv.max_idle_conns is not null. Note that the hlua code is currently safe thanks to the additional checks on proxy http mode and stream reuse policy not never. However, this might not be sufficient for future code. This patch should be backported in every branches containing the following patch : 7f68d815af356fbe1b2e1080a88b9935581c91d2 (2.4 tree) REORG: backend: simplify conn_backend_get --- diff --git a/src/backend.c b/src/backend.c index f3f42230bb..f6afde358d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1250,7 +1250,8 @@ int connect_server(struct stream *s) srv = objt_server(s->target); - if (s->be->mode != PR_MODE_HTTP) + /* do not reuse if mode is http or if avail list is not allocated */ + if ((s->be->mode != PR_MODE_HTTP) || (srv && !srv->available_conns)) goto skip_reuse; /* first, search for a matching connection in the session's idle conns */