From fa22b4ffef293af1159d2fee7b2ad45c6c8fe075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Tue, 6 Jan 2026 13:11:57 +0100 Subject: [PATCH] libcamera: base: event_dispatcher_poll: Dispatch `POLLPRI` first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `poll()` returns multiple events for a given file descriptor, while there is no general rule that requires it, for the use cases of libcamera, it is better to service priority events first. So dispatch those first, and not last. For example, a V4L2 capture device might be a source of V4L2 events (e.g. frame start) as well as a source of dequeue-able buffers. In such cases, given the appropriate scheduling, it is possible with the current event dispatch order that dequeueing the buffer happens before processing the corresponding frame start event. Such occurrence will most likely trip up any internal state machine. The above is suspected to contribute to [0], however, that is not confirmed. [0]: https://gitlab.freedesktop.org/camera/libcamera/-/issues/267 Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart Reviewed-by: Naushir Patuck --- src/libcamera/base/event_dispatcher_poll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/base/event_dispatcher_poll.cpp b/src/libcamera/base/event_dispatcher_poll.cpp index 52bfb34e..006e223f 100644 --- a/src/libcamera/base/event_dispatcher_poll.cpp +++ b/src/libcamera/base/event_dispatcher_poll.cpp @@ -244,9 +244,9 @@ void EventDispatcherPoll::processNotifiers(const std::vector &pol EventNotifier::Type type; short events; } events[] = { + { EventNotifier::Exception, POLLPRI }, { EventNotifier::Read, POLLIN }, { EventNotifier::Write, POLLOUT }, - { EventNotifier::Exception, POLLPRI }, }; processingEvents_ = true;