libcamera/include/libcamera
Barnabás Pőcze 9ac914c634 libcamera: base: log: Protect log categories with lock
Log categories may be added from any thread, so it is important to
synchronize access to the `Logger::categories_` list between its two
users: category creation (by LogCategory::create(), which calls
Logger::findCategory() and Logger::registerCategory()); and log level
setting (by Logger::logSetLevel()).

The LogCategory::create() function uses a mutex to serialize category
creation, but Logger::logSetLevel() can access `Logger::categories_`
concurrently without any protection. To fix the issue, move the mutex to
the Logger class, and use it to protect all accesses to the categories
list. This requires moving all the logic of LogCategory::create() to a
new Logger::findOrCreateCategory() function that combines both
Logger::findCategory() and Logger::registerCategory() in order to make
the two operations exacute atomically.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2025-02-27 11:30:23 +01:00
..
base libcamera: base: log: Protect log categories with lock 2025-02-27 11:30:23 +01:00
internal libcamera: Adapt Vector class to new location 2025-02-12 14:26:27 +01:00
ipa libcamera: controls: Add support for querying direction information 2024-12-18 17:27:01 +09:00
camera.h libcamera: Drop file name from header comment blocks 2024-05-08 22:39:50 +03:00
camera_manager.h libcamera: Drop file name from header comment blocks 2024-05-08 22:39:50 +03:00
color_space.h libcamera: Drop file name from header comment blocks 2024-05-08 22:39:50 +03:00
control_ids.h.in libcamera: Add debug control space 2024-11-13 11:47:06 +01:00
controls.h libcamera: controls: Add support for querying direction information 2024-12-18 17:27:01 +09:00
fence.h libcamera: Drop remaining file name from header comment blocks 2024-05-09 23:31:15 +03:00
formats.h.in libcamera: Drop file name from header comment blocks in templates 2024-05-09 23:31:14 +03:00
framebuffer.h libcamera: includes: Remove unused includes 2024-09-02 22:44:38 +03:00
framebuffer_allocator.h libcamera: Drop file name from header comment blocks 2024-05-08 22:39:50 +03:00
geometry.h libcamera: base: Remove custom __nodiscard attribute 2025-01-08 15:26:30 +00:00
logging.h libcamera: includes: Add missing includes 2024-09-02 22:37:55 +03:00
meson.build libcamera: Add debug control space 2024-11-13 11:47:06 +01:00
orientation.h libcamera: Drop file name from header comment blocks 2024-05-08 22:39:50 +03:00
pixel_format.h libcamera: includes: Remove unused includes 2024-09-02 22:44:38 +03:00
request.h libcamera: includes: Remove unused includes 2024-09-02 22:44:38 +03:00
stream.h libcamera: stream: Add operator<<(StreamConfiguration) 2024-12-11 15:39:05 +01:00
transform.h libcamera: includes: Remove unused includes 2024-09-02 22:44:38 +03:00
version.h.in libcamera: Drop file name from header comment blocks in templates 2024-05-09 23:31:14 +03:00