Message ID | 20211203164619.1541033-3-hiroh@chromium.org |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index 6bda9d14..abd33a83 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -390,9 +390,11 @@ void Thread::finishThread() * * \context This function is \threadsafe. */ -void Thread::exit(int code) +void Thread::exitint code) { + data_->mutex_.lock(); data_->exitCode_ = code; + data_->mutex_.unlock(); data_->exit_.store(true, std::memory_order_release); EventDispatcher *dispatcher = data_->dispatcher_.load(std::memory_order_relaxed);
This fixes the bug that Thread::exit() accesses data_->exitCode without acquiring a lock. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- src/libcamera/base/thread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)