From 3a7879a6525c866b1641050e28191dbcb87cc164 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 5 Jul 2024 15:27:23 +0200 Subject: [PATCH] MEDIUM: spoe: Set a specific name for the connection pool of SPOP servers With this patch, we force the connection pool name of SPOP server to the SPOE engine identifier. This way, SPOP idle connections cannot be shared between diffrente engines. The related issue is #2502. --- src/flt_spoe.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/flt_spoe.c b/src/flt_spoe.c index c31bfb192..d91002730 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -3009,6 +3009,37 @@ static int smp_fetch_spoe_engine_id(const struct arg *args, struct sample *smp, return 1; } +static int spoe_postcheck_spop_proxy(struct proxy *px) +{ + struct server *srv; + int err_code = ERR_NONE; + + if (!(px->cap & PR_CAP_BE) || px->mode != PR_MODE_SPOP) + goto out; + + for (srv = px->srv; srv; srv = srv->next) { + if (srv->pool_conn_name) { + ha_free(&srv->pool_conn_name); + release_sample_expr(srv->pool_conn_name_expr); + } + srv->pool_conn_name = strdup("spoe.engine-id"); + if (!srv->pool_conn_name) { + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + srv->pool_conn_name_expr = _parse_srv_expr(srv->pool_conn_name, &px->conf.args, NULL, 0, NULL); + if (!srv->pool_conn_name_expr) { + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + } + + out: + return err_code; +} + +REGISTER_POST_PROXY_CHECK(spoe_postcheck_spop_proxy); + /* Declare the filter parser for "spoe" keyword */ static struct flt_kw_list flt_kws = { "SPOE", { }, { { "spoe", parse_spoe_flt, NULL },