CrackMe.apk
Download file
package okhttp3.internal.connection;
import androidx.core.app.NotificationCompat;
import java.lang.ref.Reference;
import java.net.Socket;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.TimeUnit;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import okhttp3.Address;
import okhttp3.ConnectionPool;
import okhttp3.Route;
import okhttp3.internal.Util;
import okhttp3.internal.concurrent.TaskQueue;
import okhttp3.internal.concurrent.TaskRunner;
import okhttp3.internal.connection.RealCall;
import okhttp3.internal.platform.Platform;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0010\u0002\n\u0002\b\u0005*\u0001\u000e\u0018\u0000 (2\u00020\u0001:\u0001(B%\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\u0006\u0010\b\u001a\u00020\t¢\u0006\u0002\u0010\nJ.\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0016\u001a\u00020\u00172\u0006\u0010\u0018\u001a\u00020\u00192\u000e\u0010\u001a\u001a\n\u0012\u0004\u0012\u00020\u001c\u0018\u00010\u001b2\u0006\u0010\u001d\u001a\u00020\u0015J\u000e\u0010\u001e\u001a\u00020\u00072\u0006\u0010\u001f\u001a\u00020\u0007J\u000e\u0010 \u001a\u00020\u00152\u0006\u0010!\u001a\u00020\u0012J\u0006\u0010\"\u001a\u00020\u0005J\u0006\u0010#\u001a\u00020$J\u0006\u0010%\u001a\u00020\u0005J\u0018\u0010&\u001a\u00020\u00052\u0006\u0010!\u001a\u00020\u00122\u0006\u0010\u001f\u001a\u00020\u0007H\u0002J\u000e\u0010'\u001a\u00020$2\u0006\u0010!\u001a\u00020\u0012R\u000e\u0010\u000b\u001a\u00020\fX\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\r\u001a\u00020\u000eX\u0004¢\u0006\u0004\n\u0002\u0010\u000fR\u0014\u0010\u0010\u001a\b\u0012\u0004\u0012\u00020\u00120\u0011X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0013\u001a\u00020\u0007X\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0004¢\u0006\u0002\n\u0000¨\u0006)"}, d2 = {"Lokhttp3/internal/connection/RealConnectionPool;", "", "taskRunner", "Lokhttp3/internal/concurrent/TaskRunner;", "maxIdleConnections", "", "keepAliveDuration", "", "timeUnit", "Ljava/util/concurrent/TimeUnit;", "(Lokhttp3/internal/concurrent/TaskRunner;IJLjava/util/concurrent/TimeUnit;)V", "cleanupQueue", "Lokhttp3/internal/concurrent/TaskQueue;", "cleanupTask", "okhttp3/internal/connection/RealConnectionPool$cleanupTask$1", "Lokhttp3/internal/connection/RealConnectionPool$cleanupTask$1;", "connections", "Ljava/util/concurrent/ConcurrentLinkedQueue;", "Lokhttp3/internal/connection/RealConnection;", "keepAliveDurationNs", "callAcquirePooledConnection", "", "address", "Lokhttp3/Address;", "call", "Lokhttp3/internal/connection/RealCall;", "routes", "", "Lokhttp3/Route;", "requireMultiplexed", "cleanup", "now", "connectionBecameIdle", "connection", "connectionCount", "evictAll", "", "idleConnectionCount", "pruneAndGetAllocationCount", "put", "Companion", "okhttp"}, k = 1, mv = {1, 4, 0})
/* compiled from: RealConnectionPool.kt */
public final class RealConnectionPool {
public static final Companion Companion = new Companion((DefaultConstructorMarker) null);
private final TaskQueue cleanupQueue;
private final RealConnectionPool$cleanupTask$1 cleanupTask = new RealConnectionPool$cleanupTask$1(this, Util.okHttpName + " ConnectionPool");
private final ConcurrentLinkedQueue<RealConnection> connections = new ConcurrentLinkedQueue<>();
private final long keepAliveDurationNs;
private final int maxIdleConnections;
public RealConnectionPool(TaskRunner taskRunner, int i, long j, TimeUnit timeUnit) {
Intrinsics.checkNotNullParameter(taskRunner, "taskRunner");
Intrinsics.checkNotNullParameter(timeUnit, "timeUnit");
this.maxIdleConnections = i;
this.keepAliveDurationNs = timeUnit.toNanos(j);
this.cleanupQueue = taskRunner.newQueue();
if (!(j > 0)) {
throw new IllegalArgumentException(("keepAliveDuration <= 0: " + j).toString());
}
}
public final int idleConnectionCount() {
boolean isEmpty;
Iterable<RealConnection> iterable = this.connections;
int i = 0;
if (!(iterable instanceof Collection) || !((Collection) iterable).isEmpty()) {
for (RealConnection realConnection : iterable) {
Intrinsics.checkNotNullExpressionValue(realConnection, "it");
synchronized (realConnection) {
isEmpty = realConnection.getCalls().isEmpty();
}
if (isEmpty && (i = i + 1) < 0) {
CollectionsKt.throwCountOverflow();
}
}
}
return i;
}
public final int connectionCount() {
return this.connections.size();
}
public final boolean callAcquirePooledConnection(Address address, RealCall realCall, List<Route> list, boolean z) {
Intrinsics.checkNotNullParameter(address, "address");
Intrinsics.checkNotNullParameter(realCall, NotificationCompat.CATEGORY_CALL);
Iterator<RealConnection> it = this.connections.iterator();
while (it.hasNext()) {
RealConnection next = it.next();
Intrinsics.checkNotNullExpressionValue(next, "connection");
synchronized (next) {
if (z) {
if (!next.isMultiplexed$okhttp()) {
Unit unit = Unit.INSTANCE;
}
}
if (next.isEligible$okhttp(address, list)) {
realCall.acquireConnectionNoEvents(next);
return true;
}
Unit unit2 = Unit.INSTANCE;
}
}
return false;
}
public final void evictAll() {
Socket socket;
Iterator<RealConnection> it = this.connections.iterator();
Intrinsics.checkNotNullExpressionValue(it, "connections.iterator()");
while (it.hasNext()) {
RealConnection next = it.next();
Intrinsics.checkNotNullExpressionValue(next, "connection");
synchronized (next) {
if (next.getCalls().isEmpty()) {
it.remove();
next.setNoNewExchanges(true);
socket = next.socket();
} else {
socket = null;
}
}
if (socket != null) {
Util.closeQuietly(socket);
}
}
if (this.connections.isEmpty()) {
this.cleanupQueue.cancelAll();
}
}
/* JADX WARNING: Code restructure failed: missing block: B:44:0x0085, code lost:
okhttp3.internal.Util.closeQuietly(r0.socket());
*/
/* JADX WARNING: Code restructure failed: missing block: B:45:0x0092, code lost:
if (r10.connections.isEmpty() == false) goto L_0x0099;
*/
/* JADX WARNING: Code restructure failed: missing block: B:46:0x0094, code lost:
r10.cleanupQueue.cancelAll();
*/
/* JADX WARNING: Code restructure failed: missing block: B:47:0x0099, code lost:
return 0;
*/
/* Code decompiled incorrectly, please refer to instructions dump. */
public final long cleanup(long r11) {
/*
r10 = this;
r0 = 0
r1 = r0
okhttp3.internal.connection.RealConnection r1 = (okhttp3.internal.connection.RealConnection) r1
java.util.concurrent.ConcurrentLinkedQueue<okhttp3.internal.connection.RealConnection> r1 = r10.connections
java.util.Iterator r1 = r1.iterator()
r2 = 0
r3 = -9223372036854775808
r4 = r3
r3 = 0
L_0x000f:
boolean r6 = r1.hasNext()
if (r6 == 0) goto L_0x0046
java.lang.Object r6 = r1.next()
okhttp3.internal.connection.RealConnection r6 = (okhttp3.internal.connection.RealConnection) r6
java.lang.String r7 = "connection"
kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r6, r7)
monitor-enter(r6)
int r7 = r10.pruneAndGetAllocationCount(r6, r11) // Catch:{ all -> 0x0043 }
if (r7 <= 0) goto L_0x002e
int r7 = r3 + 1
java.lang.Integer.valueOf(r3) // Catch:{ all -> 0x0043 }
r3 = r7
goto L_0x0041
L_0x002e:
int r2 = r2 + 1
long r7 = r6.getIdleAtNs$okhttp() // Catch:{ all -> 0x0043 }
long r7 = r11 - r7
int r9 = (r7 > r4 ? 1 : (r7 == r4 ? 0 : -1))
if (r9 <= 0) goto L_0x003f
kotlin.Unit r0 = kotlin.Unit.INSTANCE // Catch:{ all -> 0x0043 }
r0 = r6
r4 = r7
goto L_0x0041
L_0x003f:
kotlin.Unit r7 = kotlin.Unit.INSTANCE // Catch:{ all -> 0x0043 }
L_0x0041:
monitor-exit(r6)
goto L_0x000f
L_0x0043:
r11 = move-exception
monitor-exit(r6)
throw r11
L_0x0046:
long r6 = r10.keepAliveDurationNs
int r1 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1))
if (r1 >= 0) goto L_0x005b
int r1 = r10.maxIdleConnections
if (r2 <= r1) goto L_0x0051
goto L_0x005b
L_0x0051:
if (r2 <= 0) goto L_0x0055
long r6 = r6 - r4
return r6
L_0x0055:
if (r3 <= 0) goto L_0x0058
return r6
L_0x0058:
r11 = -1
return r11
L_0x005b:
kotlin.jvm.internal.Intrinsics.checkNotNull(r0)
monitor-enter(r0)
java.util.List r1 = r0.getCalls() // Catch:{ all -> 0x009a }
java.util.Collection r1 = (java.util.Collection) r1 // Catch:{ all -> 0x009a }
boolean r1 = r1.isEmpty() // Catch:{ all -> 0x009a }
r2 = 1
r1 = r1 ^ r2
r6 = 0
if (r1 == 0) goto L_0x0071
monitor-exit(r0)
return r6
L_0x0071:
long r8 = r0.getIdleAtNs$okhttp() // Catch:{ all -> 0x009a }
long r8 = r8 + r4
int r1 = (r8 > r11 ? 1 : (r8 == r11 ? 0 : -1))
if (r1 == 0) goto L_0x007c
monitor-exit(r0)
return r6
L_0x007c:
r0.setNoNewExchanges(r2) // Catch:{ all -> 0x009a }
java.util.concurrent.ConcurrentLinkedQueue<okhttp3.internal.connection.RealConnection> r11 = r10.connections // Catch:{ all -> 0x009a }
r11.remove(r0) // Catch:{ all -> 0x009a }
monitor-exit(r0)
java.net.Socket r11 = r0.socket()
okhttp3.internal.Util.closeQuietly((java.net.Socket) r11)
java.util.concurrent.ConcurrentLinkedQueue<okhttp3.internal.connection.RealConnection> r11 = r10.connections
boolean r11 = r11.isEmpty()
if (r11 == 0) goto L_0x0099
okhttp3.internal.concurrent.TaskQueue r11 = r10.cleanupQueue
r11.cancelAll()
L_0x0099:
return r6
L_0x009a:
r11 = move-exception
monitor-exit(r0)
throw r11
*/
throw new UnsupportedOperationException("Method not decompiled: okhttp3.internal.connection.RealConnectionPool.cleanup(long):long");
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u000e\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006¨\u0006\u0007"}, d2 = {"Lokhttp3/internal/connection/RealConnectionPool$Companion;", "", "()V", "get", "Lokhttp3/internal/connection/RealConnectionPool;", "connectionPool", "Lokhttp3/ConnectionPool;", "okhttp"}, k = 1, mv = {1, 4, 0})
/* compiled from: RealConnectionPool.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final RealConnectionPool get(ConnectionPool connectionPool) {
Intrinsics.checkNotNullParameter(connectionPool, "connectionPool");
return connectionPool.getDelegate$okhttp();
}
}
public final void put(RealConnection realConnection) {
Intrinsics.checkNotNullParameter(realConnection, "connection");
if (!Util.assertionsEnabled || Thread.holdsLock(realConnection)) {
this.connections.add(realConnection);
TaskQueue.schedule$default(this.cleanupQueue, this.cleanupTask, 0, 2, (Object) null);
return;
}
StringBuilder sb = new StringBuilder();
sb.append("Thread ");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
sb.append(currentThread.getName());
sb.append(" MUST hold lock on ");
sb.append(realConnection);
throw new AssertionError(sb.toString());
}
public final boolean connectionBecameIdle(RealConnection realConnection) {
Intrinsics.checkNotNullParameter(realConnection, "connection");
if (Util.assertionsEnabled && !Thread.holdsLock(realConnection)) {
StringBuilder sb = new StringBuilder();
sb.append("Thread ");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
sb.append(currentThread.getName());
sb.append(" MUST hold lock on ");
sb.append(realConnection);
throw new AssertionError(sb.toString());
} else if (realConnection.getNoNewExchanges() || this.maxIdleConnections == 0) {
realConnection.setNoNewExchanges(true);
this.connections.remove(realConnection);
if (!this.connections.isEmpty()) {
return true;
}
this.cleanupQueue.cancelAll();
return true;
} else {
TaskQueue.schedule$default(this.cleanupQueue, this.cleanupTask, 0, 2, (Object) null);
return false;
}
}
private final int pruneAndGetAllocationCount(RealConnection realConnection, long j) {
if (!Util.assertionsEnabled || Thread.holdsLock(realConnection)) {
List<Reference<RealCall>> calls = realConnection.getCalls();
int i = 0;
while (i < calls.size()) {
Reference reference = calls.get(i);
if (reference.get() != null) {
i++;
} else {
Objects.requireNonNull(reference, "null cannot be cast to non-null type okhttp3.internal.connection.RealCall.CallReference");
Platform.Companion.get().logCloseableLeak("A connection to " + realConnection.route().address().url() + " was leaked. " + "Did you forget to close a response body?", ((RealCall.CallReference) reference).getCallStackTrace());
calls.remove(i);
realConnection.setNoNewExchanges(true);
if (calls.isEmpty()) {
realConnection.setIdleAtNs$okhttp(j - this.keepAliveDurationNs);
return 0;
}
}
}
return calls.size();
}
StringBuilder sb = new StringBuilder();
sb.append("Thread ");
Thread currentThread = Thread.currentThread();
Intrinsics.checkNotNullExpressionValue(currentThread, "Thread.currentThread()");
sb.append(currentThread.getName());
sb.append(" MUST hold lock on ");
sb.append(realConnection);
throw new AssertionError(sb.toString());
}
}
Download file