From 5ecf27681efc2f64365d552be3d695b780d533e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sun, 8 Jun 2025 21:18:34 +0200 Subject: [PATCH] pipewire: module-rt: acquire_rt(): return error if thread not found Instead of implicitly acting on the current thread if the provided thread handle is unknown, return an error. This behaviour is not depended on inside pipewire, and if needed, special casing e.g. `thread == NULL` could be added, but any random `thread` value shouldn't affect the current thread. --- src/modules/module-rt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/module-rt.c b/src/modules/module-rt.c index dcc9c31a8..2475ca6fc 100644 --- a/src/modules/module-rt.c +++ b/src/modules/module-rt.c @@ -843,16 +843,17 @@ static int impl_acquire_rt(void *object, struct spa_thread *thread, int priority pw_log_debug("SCHED_OTHER|SCHED_RESET_ON_FORK worked."); } - params.priority = priority; - pthread_mutex_lock(&impl->lock); - if ((thr = find_thread_by_pt(impl, pt)) != NULL) + if ((thr = find_thread_by_pt(impl, pt)) != NULL) { + params.priority = priority; params.tid = thr->tid; - else - params.tid = _gettid(); - res = pw_loop_invoke(pw_thread_loop_get_loop(impl->thread_loop), + res = pw_loop_invoke(pw_thread_loop_get_loop(impl->thread_loop), do_make_realtime, 0, ¶ms, sizeof(params), false, impl); + } + else { + res = -ESRCH; + } pthread_mutex_unlock(&impl->lock); return res;