From d13428f7505dd788f1219496078023a50e29def5 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 9 Jul 2024 08:24:05 +0200 Subject: [PATCH] BUG/MEDIUM: spoe: Be sure to create a SPOE applet if none on the current thread When a message is queued, waiting to be processed by a SPOE applet, there are some heuristic to know if a new applet must be created or not. There are 2 conditions to skip the applet creation: 1 - if there are enough idle applets on the current thread, or, 2 - if the processing rate on the current thread is high enough to handle this new message In the 2nd case, there is a flaw when the number of processed messages falls to zero while the processing rate is still greater than zero. In that case, we will skip the SPOE applet creation without taking care to check there is at least one applet on the current thread. So now, the conditions above to skip the SPOE applet creation are only evaluated if there is at least one applet on the current thread. This patch must be backported to every stable versions. (cherry picked from commit 5e84f13a0b3b915990a4e25ec9448fdbef3c1a14) Signed-off-by: Willy Tarreau --- src/flt_spoe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 95930f13f..c79dd07a1 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -2090,8 +2090,9 @@ spoe_queue_context(struct spoe_context *ctx) struct spoe_appctx *spoe_appctx; /* Check if we need to create a new SPOE applet or not. */ - if (agent->rt[tid].processing < agent->rt[tid].idles || - agent->rt[tid].processing < read_freq_ctr(&agent->rt[tid].processing_per_sec)) + if (!LIST_ISEMPTY(&agent->rt[tid].applets) && + (agent->rt[tid].processing < agent->rt[tid].idles || + agent->rt[tid].processing < read_freq_ctr(&agent->rt[tid].processing_per_sec))) goto end; SPOE_PRINTF(stderr, "%d.%06d [SPOE/%-15s] %s: stream=%p"