[libcamera-devel] [PATCH v4 0/3] cam: Fix races in event loop and long request processing times

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Feb 2 23:10:48 CET 2021


Hello,

Using cam to writing requests to (slow) media sometimes lock cam in an
unbreakable loop. At the heart of the problem is that when request
processing was moved from the camera to the main thread subtle races in
the cam event loop implementation where exposed.

The races are easily trigged by having callbacks injected into the even
loop that takes a long time to process. The only callbacks cam currently
injects to the event loop are processing of completed requests. So by
increasing there processing time by writing them to disk the races where
trigged.

This series aims to solve this by integrating the cam event loop closer 
with libevent. As a bonus cam can be made more strict about how it 
operates under the --capture=N mode.

Niklas Söderlund (3):
  cam: event_loop: Rename event_ to base_
  cam: event_loop: Execute events in the libevent loop
  cam: Only queue the exact number of requests asked for

 src/cam/capture.cpp    | 16 +++++++++++---
 src/cam/capture.h      |  2 ++
 src/cam/event_loop.cpp | 49 ++++++++++++++++++++----------------------
 src/cam/event_loop.h   |  8 ++-----
 4 files changed, 40 insertions(+), 35 deletions(-)

-- 
2.30.0



More information about the libcamera-devel mailing list