diff options
| author | 2021-02-07 21:16:01 +0000 | |
|---|---|---|
| committer | 2021-02-07 21:16:01 +0000 | |
| commit | f9b15d961bc89635a6020ebade0ffdd1e271de52 (patch) | |
| tree | 41e3fb8ea11fc364928ef29f59592fffcaee1e04 | |
| parent | ba898f46b45ff20403bf96f6e9a86dea07f7b9f5 (diff) | |
| parent | 255e25fcc3e75c3d2c206451288b72c36e6e5289 (diff) | |
Merge "Fix a bug in the USAP Pool refill logic." am: 905c2570cd am: 8151e4c800 am: 255e25fcc3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1573329
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I945ec7dcc3c89fe7f4cc97b248a16f256f7c0c06
| -rw-r--r-- | core/java/com/android/internal/os/ZygoteServer.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/core/java/com/android/internal/os/ZygoteServer.java b/core/java/com/android/internal/os/ZygoteServer.java index a4ce027501b8..585ddf6ddf98 100644 --- a/core/java/com/android/internal/os/ZygoteServer.java +++ b/core/java/com/android/internal/os/ZygoteServer.java @@ -492,10 +492,12 @@ class ZygoteServer { long elapsedTimeMs = System.currentTimeMillis() - mUsapPoolRefillTriggerTimestamp; if (elapsedTimeMs >= mUsapPoolRefillDelayMs) { - // Normalize the poll timeout value when the time between one poll event and the - // next pushes us over the delay value. This prevents poll receiving a 0 - // timeout value, which would result in it returning immediately. - pollTimeoutMs = -1; + // The refill delay has elapsed during the period between poll invocations. + // We will now check for any currently ready file descriptors before refilling + // the USAP pool. + pollTimeoutMs = 0; + mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; + mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED; } else if (elapsedTimeMs <= 0) { // This can occur if the clock used by currentTimeMillis is reset, which is @@ -517,9 +519,11 @@ class ZygoteServer { } if (pollReturnValue == 0) { - // The poll timeout has been exceeded. This only occurs when we have finished the - // USAP pool refill delay period. - + // The poll returned zero results either when the timeout value has been exceeded + // or when a non-blocking poll is issued and no FDs are ready. In either case it + // is time to refill the pool. This will result in a duplicate assignment when + // the non-blocking poll returns zero results, but it avoids an additional + // conditional in the else branch. mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP; mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED; |