diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2015-08-28 16:27:27 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2015-08-28 16:27:27 -0700 |
commit | efff1c4ba2bf195d97de2fd5718b708e4b942901 (patch) | |
tree | 80bd9df579b10a5bb5083383952178b9113e46eb /services | |
parent | 0b4543149bd5afa2e9ffc26baa9f472349bea201 (diff) | |
download | frameworks_av-efff1c4ba2bf195d97de2fd5718b708e4b942901.zip frameworks_av-efff1c4ba2bf195d97de2fd5718b708e4b942901.tar.gz frameworks_av-efff1c4ba2bf195d97de2fd5718b708e4b942901.tar.bz2 |
Camera3Device: Don't hold mutex during HAL device close.
The HAL device shutdown will likely need to wait on various events and
queues to drain, and holding the mutex will prevent, for example, error
notifications from being processed. This can lead to deadlocks.
Bug: 23501571
Change-Id: I873ac23ef30545adf533e7839445448573ab5048
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/device3/Camera3Device.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp index e4d75cb..ec3591f 100644 --- a/services/camera/libcameraservice/device3/Camera3Device.cpp +++ b/services/camera/libcameraservice/device3/Camera3Device.cpp @@ -285,19 +285,27 @@ status_t Camera3Device::disconnect() { mStatusTracker->join(); } + camera3_device_t *hal3Device; { Mutex::Autolock l(mLock); mRequestThread.clear(); mStatusTracker.clear(); - if (mHal3Device != NULL) { - ATRACE_BEGIN("camera3->close"); - mHal3Device->common.close(&mHal3Device->common); - ATRACE_END(); - mHal3Device = NULL; - } + hal3Device = mHal3Device; + } + + // Call close without internal mutex held, as the HAL close may need to + // wait on assorted callbacks,etc, to complete before it can return. + if (hal3Device != NULL) { + ATRACE_BEGIN("camera3->close"); + hal3Device->common.close(&hal3Device->common); + ATRACE_END(); + } + { + Mutex::Autolock l(mLock); + mHal3Device = NULL; internalUpdateStatusLocked(STATUS_UNINITIALIZED); } |