From 65ae1347c7d0495c70221dca3fdda20a04d53628 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 12 Mar 2024 07:31:56 +0100 Subject: [PATCH] BUG/MINOR: listener: Wake proxy's mngmt task up if necessary on session release When a session is released, listener_release() function is called to notify the listener. It is an opportunity to resume limited/full listeners. We first try to resume the listener owning the released session, then all limited listeners in the global queue and finally all limited listeners in the frontend's waiting queue. This last step is only performed if there is no limit applied on the frontend. Nothing is performed if the session rate is still limited. And it is an issue because if this happens for the last listener's session, there is no other event to wake the frontend's managment task up and the listener remains in the limited state. To fix the issue, when a limit is still applied on the frontent, we must compute the new wake up date from the sessions rate and schedule the frontend's managment task. It is easy to reproduce the issue in SSL by setting a maxconn and a rate limit on sessions. This patch should fix the issue #2476. It must be backported to all stable versions. --- src/listener.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/listener.c b/src/listener.c index 37d897a1da..86d4c44f5f 100644 --- a/src/listener.c +++ b/src/listener.c @@ -1602,6 +1602,22 @@ void listener_release(struct listener *l) if (fe && !MT_LIST_ISEMPTY(&fe->listener_queue) && (!fe->fe_sps_lim || freq_ctr_remain(&fe->fe_sess_per_sec, fe->fe_sps_lim, 0) > 0)) dequeue_proxy_listeners(fe); + else { + unsigned int wait; + int expire = TICK_ETERNITY; + + if (fe->fe_sps_lim && + (wait = next_event_delay(&fe->fe_sess_per_sec,fe->fe_sps_lim, 0))) { + /* we're blocking because a limit was reached on the number of + * requests/s on the frontend. We want to re-check ASAP, which + * means in 1 ms before estimated expiration date, because the + * timer will have settled down. + */ + expire = tick_first(fe->task->expire, tick_add(now_ms, wait)); + if (fe->task && tick_isset(expire)) + task_schedule(fe->task, expire); + } + } } /* Initializes the listener queues. Returns 0 on success, otherwise ERR_* flags */ -- 2.39.5