From 7f035328fb8acd90f655a632c4e102294da3b39a Mon Sep 17 00:00:00 2001 From: Umang Jain Date: Fri, 24 Sep 2021 18:35:59 +0530 Subject: android: camera_device: Fix race on queuing capture request The Camera3RequestDescriptor containing the capture request is added to the descriptors_ map after a call to CameraWorker::queueRequest(). This is a race condition since CameraWorker::queueRequest() queues requests to libcamera::Camera asynchronously. The requests may thus complete before they get added to descriptors_, in which case requestComplete() will fail to lookup the request in the map. Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Signed-off-by: Umang Jain --- src/android/camera_device.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 21844e51..ab381168 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1065,13 +1065,15 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques state_ = State::Running; } - worker_.queueRequest(descriptor.request_.get()); + CaptureRequest *request = descriptor.request_.get(); { MutexLocker descriptorsLock(descriptorsMutex_); descriptors_[descriptor.request_->cookie()] = std::move(descriptor); } + worker_.queueRequest(request); + return 0; } -- cgit v1.2.1