mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
libcamera: base: Make the registration of log categories atomic
Logger::create() is not currently thread safe and causes crashes noticeable on RaspberryPi 4. This adds a mutex around the creation of categories. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
f852b7fbc4
commit
2ccca099d3
1 changed files with 3 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <libcamera/logging.h>
|
#include <libcamera/logging.h>
|
||||||
|
|
||||||
#include <libcamera/base/backtrace.h>
|
#include <libcamera/base/backtrace.h>
|
||||||
|
#include <libcamera/base/mutex.h>
|
||||||
#include <libcamera/base/thread.h>
|
#include <libcamera/base/thread.h>
|
||||||
#include <libcamera/base/utils.h>
|
#include <libcamera/base/utils.h>
|
||||||
|
|
||||||
|
@ -788,6 +789,8 @@ LogCategory *Logger::findCategory(const char *name) const
|
||||||
*/
|
*/
|
||||||
LogCategory *LogCategory::create(const char *name)
|
LogCategory *LogCategory::create(const char *name)
|
||||||
{
|
{
|
||||||
|
static Mutex mutex_;
|
||||||
|
MutexLocker locker(mutex_);
|
||||||
LogCategory *category = Logger::instance()->findCategory(name);
|
LogCategory *category = Logger::instance()->findCategory(name);
|
||||||
|
|
||||||
if (!category) {
|
if (!category) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue