From 0e5f2d3048bc9a8ed6f36ec0de674bcdb7407b0c Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 20 May 2026 07:40:50 -0400 Subject: [PATCH] MT#55283 prevent overflow of async queue Change-Id: I0a67562b8b27b04f6e584ef0412deb35b664ef1f --- lib/codeclib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/codeclib.c b/lib/codeclib.c index a6f709b95..4ef645477 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -5062,6 +5062,7 @@ static bool __cc_async_check_busy_blocked_queue(codec_cc_t *c, const str *data, void *async_cb_obj, __typeof__(__cc_run_async) run_async) { struct async_job *j = NULL; + async_job_q overflow = TYPED_GQUEUE_INIT; { LOCK(&c->async_lock); @@ -5076,11 +5077,26 @@ static bool __cc_async_check_busy_blocked_queue(codec_cc_t *c, const str *data, // append to queue __cc_async_do_add_queue(c, data, ts, async_cb_obj); + if (c->async_jobs.length > 20) { + ilog(LOG_WARN | LOG_FLAG_LIMIT, "Async job queue overflow (%u), dropping frames", + c->async_jobs.length); + do { + __auto_type jj = t_queue_pop_head(&c->async_jobs); + t_queue_push_tail(&overflow, jj); + } while (c->async_jobs.length > 20); + } + // if we were blocked (not currently running), try running now if (c->async_blocked) j = t_queue_pop_head(&c->async_jobs); } + while (overflow.length) { + __auto_type jj = t_queue_pop_head(&overflow); + c->async_callback(NULL, jj->async_cb_obj); + __cc_async_job_free(jj); + } + if (j) { if (!run_async(c, &j->data, j->ts, j->async_cb_obj)) { // still blocked. return to queue