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

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Jan 19 13:31:08 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 fixes two different issues found when debugging this. Patch 
1/2 solves a design issue in the event loop implementation where the 
callback queue can be flooded which prevents termination of the loop.  
While patch 2/2 solves a cam design issue where the --capture=N behavior 
of only capturing N requests where broken but hidden by the problem in
patch 1/2.

Niklas Söderlund (2):
  cam: event_loop: Stop queuing calls when the event loop are exiting
  cam: Fix capturing an precis number of requests

 src/cam/capture.cpp    | 12 ++++++------
 src/cam/event_loop.cpp |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.30.0



More information about the libcamera-devel mailing list