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

Commit ab4a8ae4 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Don't hold any locks while computing the blob digest.

Computing the digest could take long and there is no need to hold
any locks for this.

Test: atest --test-mapping apex/blobstore
Change-Id: If986e90743a6fc244f3afb7615d6167790077d23
parent 251c21df
Loading
Loading
Loading
Loading
+21 −16
Original line number Diff line number Diff line
@@ -384,24 +384,27 @@ public class BlobStoreManagerService extends SystemService {
    }

    private void onStateChangedInternal(@NonNull BlobStoreSession session) {
        synchronized (mBlobsLock) {
        switch (session.getState()) {
            case STATE_ABANDONED:
            case STATE_VERIFIED_INVALID:
                session.getSessionFile().delete();
                synchronized (mBlobsLock) {
                    getUserSessionsLocked(UserHandle.getUserId(session.getOwnerUid()))
                            .remove(session.getSessionId());
                    mKnownBlobIds.remove(session.getSessionId());
                    if (LOGV) {
                        Slog.v(TAG, "Session is invalid; deleted " + session);
                    }
                }
                break;
            case STATE_COMMITTED:
                session.verifyBlobData();
                break;
            case STATE_VERIFIED_VALID:
                synchronized (mBlobsLock) {
                    final int userId = UserHandle.getUserId(session.getOwnerUid());
                    final ArrayMap<BlobHandle, BlobMetadata> userBlobs = getUserBlobsLocked(userId);
                    final ArrayMap<BlobHandle, BlobMetadata> userBlobs = getUserBlobsLocked(
                            userId);
                    BlobMetadata blob = userBlobs.get(session.getBlobHandle());
                    if (blob == null) {
                        blob = new BlobMetadata(mContext,
@@ -424,11 +427,13 @@ public class BlobStoreManagerService extends SystemService {
                    if (LOGV) {
                        Slog.v(TAG, "Successfully committed session " + session);
                    }
                }
                break;
            default:
                Slog.wtf(TAG, "Invalid session state: "
                        + stateToString(session.getState()));
        }
        synchronized (mBlobsLock) {
            try {
                writeBlobSessionsLocked();
            } catch (Exception e) {