Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efff1c4b authored by Eino-Ville Talvala's avatar Eino-Ville Talvala
Browse files

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
parent 0b454314
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -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) {
        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");
            mHal3Device->common.close(&mHal3Device->common);
        hal3Device->common.close(&hal3Device->common);
        ATRACE_END();
            mHal3Device = NULL;
    }

    {
        Mutex::Autolock l(mLock);
        mHal3Device = NULL;
        internalUpdateStatusLocked(STATUS_UNINITIALIZED);
    }