Merge "Fix a bug in the USAP Pool refill logic." am: 905c2570cd

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1573329

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I05c7564d30de66489e976d6c1343f1e3b055ac67
This commit is contained in:
Treehugger Robot
2021-02-07 20:14:52 +00:00
committed by Automerger Merge Worker

View File

@@ -492,10 +492,12 @@ class ZygoteServer {
long elapsedTimeMs = System.currentTimeMillis() - mUsapPoolRefillTriggerTimestamp; long elapsedTimeMs = System.currentTimeMillis() - mUsapPoolRefillTriggerTimestamp;
if (elapsedTimeMs >= mUsapPoolRefillDelayMs) { if (elapsedTimeMs >= mUsapPoolRefillDelayMs) {
// Normalize the poll timeout value when the time between one poll event and the // The refill delay has elapsed during the period between poll invocations.
// next pushes us over the delay value. This prevents poll receiving a 0 // We will now check for any currently ready file descriptors before refilling
// timeout value, which would result in it returning immediately. // the USAP pool.
pollTimeoutMs = -1; pollTimeoutMs = 0;
mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP;
mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED;
} else if (elapsedTimeMs <= 0) { } else if (elapsedTimeMs <= 0) {
// This can occur if the clock used by currentTimeMillis is reset, which is // This can occur if the clock used by currentTimeMillis is reset, which is
@@ -517,9 +519,11 @@ class ZygoteServer {
} }
if (pollReturnValue == 0) { if (pollReturnValue == 0) {
// The poll timeout has been exceeded. This only occurs when we have finished the // The poll returned zero results either when the timeout value has been exceeded
// USAP pool refill delay period. // 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; mUsapPoolRefillTriggerTimestamp = INVALID_TIMESTAMP;
mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED; mUsapPoolRefillAction = UsapPoolRefillAction.DELAYED;