From 848ac24490683a38d15e3e921d1dd2181fccdc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 24 Feb 2026 14:34:11 +0100 Subject: [PATCH] spa: libcamera: source: fix stop sequence Currently it is possible for the request completion handler (`impl::requestComplete`) to observe `impl::source.fd` while it is being modified in `impl::stop()`. Fix that by closing the eventfd after the camera has been stopped. Fixes: 3e28f3e8594efa ("spa: libcamera: source: rework startup sequence") --- spa/plugins/libcamera/libcamera-source.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index f0eaa68f0..c23a6fb9d 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -184,9 +184,6 @@ struct impl { 0, nullptr, 0, this ); - if (source.fd >= 0) - spa_system_close(system, std::exchange(source.fd, -1)); - camera->requestCompleted.disconnect(this, &impl::requestComplete); if (int res = camera->stop(); res < 0) { @@ -194,6 +191,9 @@ struct impl { camera->id().c_str(), spa_strerror(res)); } + if (source.fd >= 0) + spa_system_close(system, std::exchange(source.fd, -1)); + completed_requests_rb = SPA_RINGBUFFER_INIT(); active = false;