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:
committed by
Kieran Bingham
parent
f852b7fbc4
commit
2ccca099d3
@@ -21,6 +21,7 @@
|
||||
#include <libcamera/logging.h>
|
||||
|
||||
#include <libcamera/base/backtrace.h>
|
||||
#include <libcamera/base/mutex.h>
|
||||
#include <libcamera/base/thread.h>
|
||||
#include <libcamera/base/utils.h>
|
||||
|
||||
@@ -788,6 +789,8 @@ LogCategory *Logger::findCategory(const char *name) const
|
||||
*/
|
||||
LogCategory *LogCategory::create(const char *name)
|
||||
{
|
||||
static Mutex mutex_;
|
||||
MutexLocker locker(mutex_);
|
||||
LogCategory *category = Logger::instance()->findCategory(name);
|
||||
|
||||
if (!category) {
|
||||
|
||||
Reference in New Issue
Block a user