123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723 |
- .class public final Lokhttp3/ConnectionPool;
- .super Ljava/lang/Object;
- .source ""
- # static fields
- .field static final synthetic $assertionsDisabled:Z
- .field private static final executor:Ljava/util/concurrent/Executor;
- # instance fields
- .field private final cleanupRunnable:Ljava/lang/Runnable;
- .field cleanupRunning:Z
- .field private final connections:Ljava/util/Deque;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/Deque<",
- "Lokhttp3/internal/connection/RealConnection;",
- ">;"
- }
- .end annotation
- .end field
- .field private final keepAliveDurationNs:J
- .field private final maxIdleConnections:I
- .field final routeDatabase:Lokhttp3/internal/connection/RouteDatabase;
- # direct methods
- .method static constructor <clinit>()V
- .locals 9
- new-instance v8, Ljava/util/concurrent/ThreadPoolExecutor;
- const/4 v1, 0x0
- const v2, 0x7fffffff
- const-wide/16 v3, 0x3c
- sget-object v5, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
- new-instance v6, Ljava/util/concurrent/SynchronousQueue;
- invoke-direct {v6}, Ljava/util/concurrent/SynchronousQueue;-><init>()V
- const/4 v0, 0x1
- const-string v7, "OkHttp ConnectionPool"
- invoke-static {v7, v0}, Lokhttp3/internal/Util;->threadFactory(Ljava/lang/String;Z)Ljava/util/concurrent/ThreadFactory;
- move-result-object v7
- move-object v0, v8
- invoke-direct/range {v0 .. v7}, Ljava/util/concurrent/ThreadPoolExecutor;-><init>(IIJLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/ThreadFactory;)V
- sput-object v8, Lokhttp3/ConnectionPool;->executor:Ljava/util/concurrent/Executor;
- return-void
- .end method
- .method public constructor <init>()V
- .locals 4
- sget-object v0, Ljava/util/concurrent/TimeUnit;->MINUTES:Ljava/util/concurrent/TimeUnit;
- const/4 v1, 0x5
- const-wide/16 v2, 0x5
- invoke-direct {p0, v1, v2, v3, v0}, Lokhttp3/ConnectionPool;-><init>(IJLjava/util/concurrent/TimeUnit;)V
- return-void
- .end method
- .method public constructor <init>(IJLjava/util/concurrent/TimeUnit;)V
- .locals 2
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- new-instance v0, Lokhttp3/ConnectionPool$1;
- invoke-direct {v0, p0}, Lokhttp3/ConnectionPool$1;-><init>(Lokhttp3/ConnectionPool;)V
- iput-object v0, p0, Lokhttp3/ConnectionPool;->cleanupRunnable:Ljava/lang/Runnable;
- new-instance v0, Ljava/util/ArrayDeque;
- invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
- iput-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- new-instance v0, Lokhttp3/internal/connection/RouteDatabase;
- invoke-direct {v0}, Lokhttp3/internal/connection/RouteDatabase;-><init>()V
- iput-object v0, p0, Lokhttp3/ConnectionPool;->routeDatabase:Lokhttp3/internal/connection/RouteDatabase;
- iput p1, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I
- invoke-virtual {p4, p2, p3}, Ljava/util/concurrent/TimeUnit;->toNanos(J)J
- move-result-wide v0
- iput-wide v0, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J
- const-wide/16 v0, 0x0
- cmp-long p1, p2, v0
- if-lez p1, :cond_0
- return-void
- :cond_0
- new-instance p1, Ljava/lang/IllegalArgumentException;
- new-instance p4, Ljava/lang/StringBuilder;
- invoke-direct {p4}, Ljava/lang/StringBuilder;-><init>()V
- const-string v0, "keepAliveDuration <= 0: "
- invoke-virtual {p4, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p4, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
- invoke-virtual {p4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p2
- invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p1
- .end method
- .method private pruneAndGetAllocationCount(Lokhttp3/internal/connection/RealConnection;J)I
- .locals 6
- iget-object v0, p1, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List;
- const/4 v1, 0x0
- const/4 v2, 0x0
- :cond_0
- :goto_0
- invoke-interface {v0}, Ljava/util/List;->size()I
- move-result v3
- if-ge v2, v3, :cond_2
- invoke-interface {v0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
- move-result-object v3
- check-cast v3, Ljava/lang/ref/Reference;
- invoke-virtual {v3}, Ljava/lang/ref/Reference;->get()Ljava/lang/Object;
- move-result-object v4
- if-eqz v4, :cond_1
- add-int/lit8 v2, v2, 0x1
- goto :goto_0
- :cond_1
- check-cast v3, Lokhttp3/internal/connection/StreamAllocation$StreamAllocationReference;
- new-instance v4, Ljava/lang/StringBuilder;
- invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
- const-string v5, "A connection to "
- invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p1}, Lokhttp3/internal/connection/RealConnection;->route()Lokhttp3/Route;
- move-result-object v5
- invoke-virtual {v5}, Lokhttp3/Route;->address()Lokhttp3/Address;
- move-result-object v5
- invoke-virtual {v5}, Lokhttp3/Address;->url()Lokhttp3/HttpUrl;
- move-result-object v5
- invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
- const-string v5, " was leaked. Did you forget to close a response body?"
- invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v4
- invoke-static {}, Lokhttp3/internal/platform/Platform;->get()Lokhttp3/internal/platform/Platform;
- move-result-object v5
- iget-object v3, v3, Lokhttp3/internal/connection/StreamAllocation$StreamAllocationReference;->callStackTrace:Ljava/lang/Object;
- invoke-virtual {v5, v4, v3}, Lokhttp3/internal/platform/Platform;->logCloseableLeak(Ljava/lang/String;Ljava/lang/Object;)V
- invoke-interface {v0, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object;
- const/4 v3, 0x1
- iput-boolean v3, p1, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z
- invoke-interface {v0}, Ljava/util/List;->isEmpty()Z
- move-result v3
- if-eqz v3, :cond_0
- iget-wide v2, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J
- sub-long/2addr p2, v2
- iput-wide p2, p1, Lokhttp3/internal/connection/RealConnection;->idleAtNanos:J
- return v1
- :cond_2
- invoke-interface {v0}, Ljava/util/List;->size()I
- move-result p1
- return p1
- .end method
- # virtual methods
- .method cleanup(J)J
- .locals 11
- monitor-enter p0
- :try_start_0
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
- move-result-object v0
- const/4 v1, 0x0
- const/4 v2, 0x0
- const-wide/high16 v3, -0x8000000000000000L
- move-object v5, v2
- const/4 v2, 0x0
- const/4 v6, 0x0
- :cond_0
- :goto_0
- invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
- move-result v7
- if-eqz v7, :cond_2
- invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v7
- check-cast v7, Lokhttp3/internal/connection/RealConnection;
- invoke-direct {p0, v7, p1, p2}, Lokhttp3/ConnectionPool;->pruneAndGetAllocationCount(Lokhttp3/internal/connection/RealConnection;J)I
- move-result v8
- if-lez v8, :cond_1
- add-int/lit8 v6, v6, 0x1
- goto :goto_0
- :cond_1
- add-int/lit8 v2, v2, 0x1
- iget-wide v8, v7, Lokhttp3/internal/connection/RealConnection;->idleAtNanos:J
- sub-long v8, p1, v8
- cmp-long v10, v8, v3
- if-lez v10, :cond_0
- move-object v5, v7
- move-wide v3, v8
- goto :goto_0
- :cond_2
- iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J
- cmp-long v0, v3, p1
- if-gez v0, :cond_6
- iget p1, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I
- if-le v2, p1, :cond_3
- goto :goto_1
- :cond_3
- if-lez v2, :cond_4
- iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J
- sub-long/2addr p1, v3
- monitor-exit p0
- return-wide p1
- :cond_4
- if-lez v6, :cond_5
- iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J
- monitor-exit p0
- return-wide p1
- :cond_5
- iput-boolean v1, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z
- const-wide/16 p1, -0x1
- monitor-exit p0
- return-wide p1
- :cond_6
- :goto_1
- iget-object p1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {p1, v5}, Ljava/util/Deque;->remove(Ljava/lang/Object;)Z
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- invoke-virtual {v5}, Lokhttp3/internal/connection/RealConnection;->socket()Ljava/net/Socket;
- move-result-object p1
- invoke-static {p1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/net/Socket;)V
- const-wide/16 p1, 0x0
- return-wide p1
- :catchall_0
- move-exception p1
- :try_start_1
- monitor-exit p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- goto :goto_3
- :goto_2
- throw p1
- :goto_3
- goto :goto_2
- .end method
- .method connectionBecameIdle(Lokhttp3/internal/connection/RealConnection;)Z
- .locals 1
- iget-boolean v0, p1, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z
- if-nez v0, :cond_1
- iget v0, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I
- if-nez v0, :cond_0
- goto :goto_0
- :cond_0
- invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
- const/4 p1, 0x0
- return p1
- :cond_1
- :goto_0
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0, p1}, Ljava/util/Deque;->remove(Ljava/lang/Object;)Z
- const/4 p1, 0x1
- return p1
- .end method
- .method public declared-synchronized connectionCount()I
- .locals 1
- monitor-enter p0
- :try_start_0
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0}, Ljava/util/Deque;->size()I
- move-result v0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return v0
- :catchall_0
- move-exception v0
- monitor-exit p0
- throw v0
- .end method
- .method deduplicate(Lokhttp3/Address;Lokhttp3/internal/connection/StreamAllocation;)Ljava/net/Socket;
- .locals 3
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
- move-result-object v0
- :cond_0
- invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
- move-result v1
- const/4 v2, 0x0
- if-eqz v1, :cond_1
- invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v1
- check-cast v1, Lokhttp3/internal/connection/RealConnection;
- invoke-virtual {v1, p1, v2}, Lokhttp3/internal/connection/RealConnection;->isEligible(Lokhttp3/Address;Lokhttp3/Route;)Z
- move-result v2
- if-eqz v2, :cond_0
- invoke-virtual {v1}, Lokhttp3/internal/connection/RealConnection;->isMultiplexed()Z
- move-result v2
- if-eqz v2, :cond_0
- invoke-virtual {p2}, Lokhttp3/internal/connection/StreamAllocation;->connection()Lokhttp3/internal/connection/RealConnection;
- move-result-object v2
- if-eq v1, v2, :cond_0
- invoke-virtual {p2, v1}, Lokhttp3/internal/connection/StreamAllocation;->releaseAndAcquire(Lokhttp3/internal/connection/RealConnection;)Ljava/net/Socket;
- move-result-object p1
- return-object p1
- :cond_1
- return-object v2
- .end method
- .method public evictAll()V
- .locals 4
- new-instance v0, Ljava/util/ArrayList;
- invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
- monitor-enter p0
- :try_start_0
- iget-object v1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
- move-result-object v1
- :cond_0
- :goto_0
- invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
- move-result v2
- if-eqz v2, :cond_1
- invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v2
- check-cast v2, Lokhttp3/internal/connection/RealConnection;
- iget-object v3, v2, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List;
- invoke-interface {v3}, Ljava/util/List;->isEmpty()Z
- move-result v3
- if-eqz v3, :cond_0
- const/4 v3, 0x1
- iput-boolean v3, v2, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z
- invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
- invoke-interface {v1}, Ljava/util/Iterator;->remove()V
- goto :goto_0
- :cond_1
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
- move-result-object v0
- :goto_1
- invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
- move-result v1
- if-eqz v1, :cond_2
- invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v1
- check-cast v1, Lokhttp3/internal/connection/RealConnection;
- invoke-virtual {v1}, Lokhttp3/internal/connection/RealConnection;->socket()Ljava/net/Socket;
- move-result-object v1
- invoke-static {v1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/net/Socket;)V
- goto :goto_1
- :cond_2
- return-void
- :catchall_0
- move-exception v0
- :try_start_1
- monitor-exit p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- goto :goto_3
- :goto_2
- throw v0
- :goto_3
- goto :goto_2
- .end method
- .method get(Lokhttp3/Address;Lokhttp3/internal/connection/StreamAllocation;Lokhttp3/Route;)Lokhttp3/internal/connection/RealConnection;
- .locals 3
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
- move-result-object v0
- :cond_0
- invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
- move-result v1
- if-eqz v1, :cond_1
- invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v1
- check-cast v1, Lokhttp3/internal/connection/RealConnection;
- invoke-virtual {v1, p1, p3}, Lokhttp3/internal/connection/RealConnection;->isEligible(Lokhttp3/Address;Lokhttp3/Route;)Z
- move-result v2
- if-eqz v2, :cond_0
- const/4 p1, 0x1
- invoke-virtual {p2, v1, p1}, Lokhttp3/internal/connection/StreamAllocation;->acquire(Lokhttp3/internal/connection/RealConnection;Z)V
- return-object v1
- :cond_1
- const/4 p1, 0x0
- return-object p1
- .end method
- .method public declared-synchronized idleConnectionCount()I
- .locals 3
- monitor-enter p0
- const/4 v0, 0x0
- :try_start_0
- iget-object v1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
- move-result-object v1
- :cond_0
- :goto_0
- invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
- move-result v2
- if-eqz v2, :cond_1
- invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
- move-result-object v2
- check-cast v2, Lokhttp3/internal/connection/RealConnection;
- iget-object v2, v2, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List;
- invoke-interface {v2}, Ljava/util/List;->isEmpty()Z
- move-result v2
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- if-eqz v2, :cond_0
- add-int/lit8 v0, v0, 0x1
- goto :goto_0
- :cond_1
- monitor-exit p0
- return v0
- :catchall_0
- move-exception v0
- monitor-exit p0
- goto :goto_2
- :goto_1
- throw v0
- :goto_2
- goto :goto_1
- .end method
- .method put(Lokhttp3/internal/connection/RealConnection;)V
- .locals 2
- iget-boolean v0, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z
- if-nez v0, :cond_0
- const/4 v0, 0x1
- iput-boolean v0, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z
- sget-object v0, Lokhttp3/ConnectionPool;->executor:Ljava/util/concurrent/Executor;
- iget-object v1, p0, Lokhttp3/ConnectionPool;->cleanupRunnable:Ljava/lang/Runnable;
- invoke-interface {v0, v1}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
- :cond_0
- iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque;
- invoke-interface {v0, p1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z
- return-void
- .end method
|