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

Commit 39c0550a authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

Merge "Fix AppFuse deadlock." into main

parents d87e0e9a 2d5b4c9d
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -3651,7 +3651,26 @@ class StorageManagerService extends IStorageManager.Stub
            Watchdog.getInstance().pauseWatchingMonitorsFor(
                SLOW_OPERATION_WATCHDOG_TIMEOUT_MS, "#close might be slow");
            if (mMounted) {
                BackgroundThread.getHandler().post(() -> {
                    try {
                        // We need to run the unmount on a separate thread to
                        // prevent a possible deadlock, where:
                        // 1. AppFuseThread (this thread) tries to call into vold
                        // 2. the vold lock is held by another thread, which called:
                        //    mVold.openAppFuseFile()
                        //    as part of that call, vold calls open() on the
                        //    underlying file, which is a call that needs to be
                        //    handled by the AppFuseThread, which is stuck waiting
                        //    for the vold lock (see 1.)
                        // It is safe to do the unmount asynchronously, because the mount
                        // path we use is never reused during the current boot cycle;
                        // see mNextAppFuseName. Also,we have anyway stopped serving
                        // requests at this point.
                        mVold.unmountAppFuse(uid, mountId);
                    } catch (RemoteException e) {
                        throw e.rethrowAsRuntimeException();
                    }
                });
                mMounted = false;
            }
        }