LockSettingsStorage: fix concurrent read clobbering a removal
Since Cache.remove() doesn't increment mVersion, the key removal can be clobbered by a concurrent read that loads the key into the cache. Fix this by making Cache.remove() increment mVersion, indicating that the backing storage has been modified. Found by code review; this bug isn't known to have been causing any real-world problems. Add a best-effort test for this, though due to the very tight race needed, it didn't reproduce the bug in 2000 iterations. However, it reproduced the bug in just a few iterations if a 1 millisecond sleep is added in the right place (just before the call to Cache.putKeyValueIfUnchanged() in LockSettingsStorage.readKeyValue()). Test: atest --iterations 50 LockSettingsStorageTests Change-Id: I960cc386ecd040af7517d3d62a3eefe57a518620
Loading
Please register or sign in to comment