Skip to content
Commit 5513817c authored by Lee Shombert's avatar Lee Shombert
Browse files

Avoid ANRs in dumpCacheInfo

Bug: 233566891

PropertyInvalidatedCache.dumpCacheInfo() sometimes triggers an ANR in
system_server, with a thread blocked writing to dumpsys TransferPipe
while holding a cache lock.  Other threads are blocked on the cache
lock.  There does not seem be a true deadlock, but if IO is slow then
all the threads slow down enough to trigger the ANR.

This change stages the output of dumpCacheInfo() in a byte array. The
byte array is written while holding the appropriate cache locks.  When
the byte array has been completely generated and all locks have been
released, the output is sent back to the caller over the dumpsys
TransferPipe.

The two PrintWriter objects are properly closed now.  The previous
code worked as a side effect of the many calls to flush(), which are
unnecessary now.

As a consequence of this change, it will be possible add a unit-test
for the output of 'dumpsys cacheinfo' by calling the method that
creates the byte array.  Such a unit test is not part of this commit.cache.

Tested manually by running 'dumpsys cacheinfo' and verifying that the
output is correct.

Test:
 * FrameworksCoreTests:IpcDataCacheTest

Change-Id: Icbd0197ca883cf0560ba2eb637951abee033eced
parent 1ae18287
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