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

Skip to content
Commit de91ac34 authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix deadlock when using PackageManagerLocal while holding mLock.

The lock order requires obtaining mSnapshotLock before mLock, however
if a caller is called under mLock and tries to use
PackageManagerLocal, it will call snapshotComputer() which will try to
obtain mSnapshotLock and result in a deadlock.

However, actually mSnapshotLock is just a preliminary check that
exists as a less contended lock than mLock - it adds a third layer
between the regular double checked locking, but still always requires
holding the final mLock before actual mutations.

So if the caller is already holding mLock, we can simply let it
rebuild the snapshot directly when necessary. And in terms of the
triple checked locking, we just need to check whether sSnapshot has
become up-to-date again after obtaining mLock in the normal path.

Fixes: 263455681
Test: manual
Change-Id: I7d00ff2091331d02dc666f09cb62523679009300
parent 3690ef88
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment