diff options
| author | Neil Fuller <nfuller@google.com> | 2014-12-01 10:11:10 +0000 |
|---|---|---|
| committer | Neil Fuller <nfuller@google.com> | 2014-12-02 15:57:29 +0000 |
| commit | 351b2ea7014d12c2e08eff6d22ac6dfbb85ce691 (patch) | |
| tree | cdb5603a59a5b5143a40bda4de683d0b45cab4e8 /okhttp | |
| parent | 442180cdae6a99817e98724901cb5f5263025e64 (diff) | |
| download | android_external_okhttp-351b2ea7014d12c2e08eff6d22ac6dfbb85ce691.tar.gz android_external_okhttp-351b2ea7014d12c2e08eff6d22ac6dfbb85ce691.tar.bz2 android_external_okhttp-351b2ea7014d12c2e08eff6d22ac6dfbb85ce691.zip | |
Fixes to ConnectionPool noticed during upstream review
Suggested by Jake Wharton. Minor documentation fixes, plus:
The pool should explicitly re-enter DRAINING state if a
connection is added to a drained pool. This state change was
missing.
The pool was implicitly in DRAINING while the pool still had
connections in it, so the pool would still drain.
However, adding back connections to a pool that was DRAINING
but still incorrectly marked as DRAINED would cause a
new runnable to be scheduled. This would cause the queue of
scheduled items to grow unnecesarily and the clean up thread
would continue to operate longer than necessary.
Bug: 18369687
(cherry picked from commit 6257f0c1c5e6e94d446051f856207782d7188c43)
Change-Id: Id60486a70163679d4f587ea75b71fc438a1d8df0
Diffstat (limited to 'okhttp')
| -rw-r--r-- | okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java b/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java index 5319a9f..1840701 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java +++ b/okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java @@ -90,7 +90,7 @@ public class ConnectionPool { */ NORMAL, /** - * Entered when a pool as been orphaned and is not expected to receive more usage, except for + * Entered when a pool has been orphaned and is not expected to receive more usage, except for * references held by existing connections. See {@link #enterDrainMode()}. * A thread runs periodically to close idle connections in the pool until the pool is empty and * then the state moves to {@link #DRAINED}. @@ -346,7 +346,7 @@ public class ConnectionPool { } } - // Callers must synchronize on "this" for the cleanMode check to be reliable. + // Callers must synchronize on "this". private void scheduleCleanupAsRequired() { switch (cleanMode) { case NORMAL: @@ -358,6 +358,7 @@ public class ConnectionPool { break; case DRAINED: // A new connection has potentially been offered up to a drained pool. Restart the drain. + cleanMode = CleanMode.DRAINING; executorService.execute(drainModeRunnable); break; } |
