summaryrefslogtreecommitdiff
path: root/libs/androidfw/StringPool.cpp
diff options
context:
space:
mode:
author Lee Shombert <shombert@google.com> 2022-06-02 15:35:16 -0700
committer Lee Shombert <shombert@google.com> 2022-06-07 15:25:03 +0000
commit5513817c765df5a104013a77396c2ecc0ef69a13 (patch)
tree20a4dc1170634302a394b12f4169f63899b84c9d /libs/androidfw/StringPool.cpp
parent1ae182872906105038e871e928cda5bfce6d21a3 (diff)
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
Diffstat (limited to 'libs/androidfw/StringPool.cpp')
0 files changed, 0 insertions, 0 deletions