Skip to content

Commit 73c1924

Browse files
chriswailesbgcngm
authored andcommitted
Fix a bug in the USAP Pool refill logic.
This CL addresses a bug in the USAP Pool refill logic that could cause refill events to be delayed indefinitely. This would not prevent future refill events from triggering, but could cause temporary degradation in USAP performance. Test: launch applications from USAP pool and inspect log Bug: 177795408 Merged-In: I2e46eae431a1d9671d31c29b3552cd0287c66239 Change-Id: I2e46eae431a1d9671d31c29b3552cd0287c66239
1 parent ea71eff commit 73c1924

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

core/java/com/android/internal/os/ZygoteServer.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,12 @@ Runnable runSelectLoop(String abiList) {
492492
long elapsedTimeMs = System.currentTimeMillis() - mUsapPoolRefillTriggerTimestamp;
493493

494494
if (elapsedTimeMs >= mUsapPoolRefillDelayMs) {
495-
// Normalize the poll timeout value when the time between one poll event and the
496-
// next pushes us over the delay value. This prevents poll receiving a 0
497-
// timeout value, which would result in it returning immediately.
498-
pollTimeoutMs = -1;
495+
// The refill delay has elapsed during the period between poll invocations.
496+
// We will now check for any currently ready file descriptors before refilling
497+
// the USAP pool.
498+
pollTimeoutMs = 0;
499+
mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP;
500+
mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED;
499501

500502
} else if (elapsedTimeMs <= 0) {
501503
// This can occur if the clock used by currentTimeMillis is reset, which is
@@ -517,9 +519,11 @@ Runnable runSelectLoop(String abiList) {
517519
}
518520

519521
if (pollReturnValue == 0) {
520-
// The poll timeout has been exceeded. This only occurs when we have finished the
521-
// USAP pool refill delay period.
522-
522+
// The poll returned zero results either when the timeout value has been exceeded
523+
// or when a non-blocking poll is issued and no FDs are ready. In either case it
524+
// is time to refill the pool. This will result in a duplicate assignment when
525+
// the non-blocking poll returns zero results, but it avoids an additional
526+
// conditional in the else branch.
523527
mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP;
524528
mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED;
525529

0 commit comments

Comments
 (0)