package 㿎.ሽ.㿎;

import java.io.Closeable;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.Socket;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import okhttp3.internal.http2.ConnectionShutdownException;
import okhttp3.internal.http2.ErrorCode;
import okio.ByteString;
import ඓ.K.K.K.C1293;
import ᨨ.AbstractC1483;
import ᨨ.AbstractC1496;
import ᨨ.C1492;
import 㿎.ሽ.AbstractRunnableC2561;
import 㿎.ሽ.C2540;
import 㿎.ሽ.ᨨ.C2558;
import 㿎.ሽ.㿎.AbstractC2605;
import 㿎.ሽ.㿎.C2611;

/* renamed from: 㿎.ሽ.㿎.ඓ  reason: contains not printable characters */
/* compiled from: Http2Connection */
public final class C2591 implements Closeable {

    /* renamed from: 㶋  reason: contains not printable characters */
    public static final ExecutorService f8715 = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), C2540.m6649("OkHttp Http2Connection", true));

    /* renamed from: ʬ  reason: contains not printable characters */
    public final AbstractC2603 f8716;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public long f8717;

    /* renamed from: Ԛ  reason: contains not printable characters */
    public final Set<Integer> f8718 = new LinkedHashSet();

    /* renamed from: ؿ  reason: contains not printable characters */
    public final C2615 f8719 = new C2615();

    /* renamed from: ݜ  reason: contains not printable characters */
    public final C2607 f8720;

    /* renamed from: ඓ  reason: contains not printable characters */
    public final String f8721;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public boolean f8722 = false;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public final AbstractC2605 f8723;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public final ScheduledExecutorService f8724;

    /* renamed from: ῲ  reason: contains not printable characters */
    public final boolean f8725;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public int f8726;

    /* renamed from: 㑃  reason: contains not printable characters */
    public boolean f8727;

    /* renamed from: 㗗  reason: contains not printable characters */
    public C2615 f8728 = new C2615();

    /* renamed from: 㗽  reason: contains not printable characters */
    public final Socket f8729;

    /* renamed from: 㳳  reason: contains not printable characters */
    public final ExecutorService f8730;

    /* renamed from: 㴹  reason: contains not printable characters */
    public int f8731;

    /* renamed from: 㸾  reason: contains not printable characters */
    public final Map<Integer, C2621> f8732 = new LinkedHashMap();

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f8733;

    /* renamed from: 䀟  reason: contains not printable characters */
    public final C2598 f8734;

    /* renamed from: 䁗  reason: contains not printable characters */
    public long f8735 = 0;

    /* renamed from: 㿎.ሽ.㿎.ඓ$ʬ  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2592 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8736;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ List f8738;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2592(String str, Object[] objArr, int i, List list) {
            super(str, objArr);
            this.f8736 = i;
            this.f8738 = list;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6824() {
            ((AbstractC2605.C2606) C2591.this.f8723).m6845(this.f8736, this.f8738);
            try {
                C2591.this.f8720.m6855(this.f8736, ErrorCode.CANCEL);
                synchronized (C2591.this) {
                    C2591.this.f8718.remove(Integer.valueOf(this.f8736));
                }
            } catch (IOException unused) {
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$ඓ  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2593 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8739;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ int f8740;

        /* renamed from: 㴹  reason: contains not printable characters */
        public final /* synthetic */ boolean f8742;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ C1492 f8743;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2593(String str, Object[] objArr, int i, C1492 r5, int i2, boolean z) {
            super(str, objArr);
            this.f8739 = i;
            this.f8743 = r5;
            this.f8740 = i2;
            this.f8742 = z;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6825() {
            try {
                ((AbstractC2605.C2606) C2591.this.f8723).m6847(this.f8739, this.f8743, this.f8740, this.f8742);
                C2591.this.f8720.m6855(this.f8739, ErrorCode.CANCEL);
                synchronized (C2591.this) {
                    C2591.this.f8718.remove(Integer.valueOf(this.f8739));
                }
            } catch (IOException unused) {
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$ᨨ  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public final class C2594 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final boolean f8744;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final int f8745;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final int f8747;

        public C2594(boolean z, int i, int i2) {
            super("OkHttp %s ping %08x%08x", C2591.this.f8721, Integer.valueOf(i), Integer.valueOf(i2));
            this.f8744 = z;
            this.f8747 = i;
            this.f8745 = i2;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6826() {
            C2591.this.m6822(this.f8744, this.f8747, this.f8745);
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$ῲ  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2595 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8748;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ long f8750;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2595(String str, Object[] objArr, int i, long j) {
            super(str, objArr);
            this.f8748 = i;
            this.f8750 = j;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6827() {
            try {
                C2591.this.f8720.m6854(this.f8748, this.f8750);
            } catch (IOException unused) {
                C2591.this.m6807();
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$ⁱ  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public static class C2596 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public AbstractC1496 f8751;

        /* renamed from: ඓ  reason: contains not printable characters */
        public AbstractC2603 f8752 = AbstractC2603.f8774;

        /* renamed from: ῲ  reason: contains not printable characters */
        public String f8753;

        /* renamed from: ⁱ  reason: contains not printable characters */
        public boolean f8754;

        /* renamed from: K  reason: contains not printable characters */
        public Socket f8755;

        /* renamed from: 㴹  reason: contains not printable characters */
        public AbstractC2605 f8756 = AbstractC2605.f8775;

        /* renamed from: 㸾  reason: contains not printable characters */
        public AbstractC1483 f8757;

        /* renamed from: 㿎  reason: contains not printable characters */
        public int f8758;

        public C2596(boolean z) {
            this.f8754 = z;
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$K  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2597 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8759;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ ErrorCode f8761;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2597(String str, Object[] objArr, int i, ErrorCode errorCode) {
            super(str, objArr);
            this.f8759 = i;
            this.f8761 = errorCode;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6828() {
            try {
                C2591 r0 = C2591.this;
                r0.f8720.m6855(this.f8759, this.f8761);
            } catch (IOException unused) {
                C2591.this.m6807();
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$㴹  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2601 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8767;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ ErrorCode f8769;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2601(String str, Object[] objArr, int i, ErrorCode errorCode) {
            super(str, objArr);
            this.f8767 = i;
            this.f8769 = errorCode;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6839() {
            ((AbstractC2605.C2606) C2591.this.f8723).m6844(this.f8767, this.f8769);
            synchronized (C2591.this) {
                C2591.this.f8718.remove(Integer.valueOf(this.f8767));
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$㸾  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2602 extends AbstractRunnableC2561 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ int f8770;

        /* renamed from: ඓ  reason: contains not printable characters */
        public final /* synthetic */ boolean f8771;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final /* synthetic */ List f8773;

        /* JADX INFO: super call moved to the top of the method (can break code semantics) */
        public C2602(String str, Object[] objArr, int i, List list, boolean z) {
            super(str, objArr);
            this.f8770 = i;
            this.f8773 = list;
            this.f8771 = z;
        }

        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6840() {
            ((AbstractC2605.C2606) C2591.this.f8723).m6846(this.f8770, this.f8773, this.f8771);
            try {
                C2591.this.f8720.m6855(this.f8770, ErrorCode.CANCEL);
                synchronized (C2591.this) {
                    C2591.this.f8718.remove(Integer.valueOf(this.f8770));
                }
            } catch (IOException unused) {
            }
        }
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$㿎  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public static abstract class AbstractC2603 {

        /* renamed from: K  reason: contains not printable characters */
        public static final AbstractC2603 f8774 = new C2604();

        /* renamed from: 㿎.ሽ.㿎.ඓ$㿎$K  reason: contains not printable characters */
        /* compiled from: Http2Connection */
        public class C2604 extends AbstractC2603 {
            @Override // 㿎.ሽ.㿎.C2591.AbstractC2603
            /* renamed from: K  reason: contains not printable characters */
            public void m6843(C2621 r2) throws IOException {
                r2.m6906(ErrorCode.REFUSED_STREAM);
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6841(C2591 r1) {
        }

        /* renamed from: K  reason: contains not printable characters */
        public abstract void m6842(C2621 v) throws IOException;
    }

    public C2591(C2596 r22) {
        this.f8723 = r22.f8756;
        boolean z = r22.f8754;
        this.f8725 = z;
        this.f8716 = r22.f8752;
        this.f8726 = z ? 1 : 2;
        if (r22.f8754) {
            this.f8726 += 2;
        }
        if (r22.f8754) {
            this.f8728.m6885(7, 16777216);
        }
        this.f8721 = r22.f8753;
        this.f8724 = new ScheduledThreadPoolExecutor(1, new C2540.ThreadFactoryC2541(C2540.m6642("OkHttp %s Writer", this.f8721), false));
        if (r22.f8758 != 0) {
            ScheduledExecutorService scheduledExecutorService = this.f8724;
            C2594 r7 = new C2594(false, 0, 0);
            int i = r22.f8758;
            scheduledExecutorService.scheduleAtFixedRate(r7, (long) i, (long) i, TimeUnit.MILLISECONDS);
        }
        this.f8730 = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue(), new C2540.ThreadFactoryC2541(C2540.m6642("OkHttp %s Push Observer", this.f8721), true));
        this.f8719.m6885(7, 65535);
        this.f8719.m6885(5, 16384);
        this.f8717 = (long) this.f8719.m6884();
        this.f8729 = r22.f8755;
        this.f8720 = new C2607(r22.f8757, this.f8725);
        this.f8734 = new C2598(new C2611(r22.f8751, this.f8725));
    }

    @Override // java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        m6820(ErrorCode.NO_ERROR, ErrorCode.CANCEL);
    }

    public void flush() throws IOException {
        this.f8720.flush();
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public synchronized C2621 m6805(int i) {
        C2621 remove;
        remove = this.f8732.remove(Integer.valueOf(i));
        notifyAll();
        return remove;
    }

    /* renamed from: ᕣ  reason: contains not printable characters */
    public synchronized int m6806() {
        int i;
        C2615 r0 = this.f8719;
        i = Integer.MAX_VALUE;
        if ((r0.f8823 & 16) != 0) {
            i = r0.f8822[4];
        }
        return i;
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public final void m6807() {
        try {
            m6820(ErrorCode.PROTOCOL_ERROR, ErrorCode.PROTOCOL_ERROR);
        } catch (IOException unused) {
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m6809(int i, ErrorCode errorCode) {
        try {
            this.f8724.execute(new C2597("OkHttp %s stream %d", new Object[]{this.f8721, Integer.valueOf(i)}, i, errorCode));
        } catch (RejectedExecutionException unused) {
        }
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public boolean m6810(int i) {
        return i != 0 && (i & 1) == 0;
    }

    /* renamed from: ⁱ  reason: contains not printable characters */
    public synchronized void m6811(long j) {
        this.f8735 += j;
        if (this.f8735 >= ((long) (this.f8728.m6884() / 2))) {
            m6814(0, this.f8735);
            this.f8735 = 0;
        }
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public synchronized boolean m6823() {
        return this.f8733;
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m6808(int i, List<C2614> list, boolean z) {
        try {
            m6821(new C2602("OkHttp %s Push Headers[%s]", new Object[]{this.f8721, Integer.valueOf(i)}, i, list, z));
        } catch (RejectedExecutionException unused) {
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public synchronized C2621 m6812(int i) {
        return this.f8732.get(Integer.valueOf(i));
    }

    /* JADX WARNING: Removed duplicated region for block: B:21:0x0043  */
    /* renamed from: K  reason: contains not printable characters */
    public final C2621 m6813(int i, List<C2614> list, boolean z) throws IOException {
        int i2;
        C2621 r9;
        boolean z2;
        boolean z3 = !z;
        synchronized (this.f8720) {
            synchronized (this) {
                if (this.f8726 > 1073741823) {
                    m6819(ErrorCode.REFUSED_STREAM);
                }
                if (!this.f8733) {
                    i2 = this.f8726;
                    this.f8726 += 2;
                    r9 = new C2621(i2, this, z3, false, list);
                    if (z && this.f8717 != 0) {
                        if (r9.f8855 != 0) {
                            z2 = false;
                            if (r9.m6900()) {
                                this.f8732.put(Integer.valueOf(i2), r9);
                            }
                        }
                    }
                    z2 = true;
                    if (r9.m6900()) {
                    }
                } else {
                    throw new ConnectionShutdownException();
                }
            }
            if (i == 0) {
                this.f8720.m6851(z3, i2, list);
            } else if (!this.f8725) {
                this.f8720.m6853(i, i2, list);
            } else {
                throw new IllegalArgumentException("client streams shouldn't have associated stream IDs");
            }
        }
        if (z2) {
            this.f8720.flush();
        }
        return r9;
    }

    /* renamed from: 㿎.ሽ.㿎.ඓ$㳳  reason: contains not printable characters */
    /* compiled from: Http2Connection */
    public class C2598 extends AbstractRunnableC2561 implements C2611.AbstractC2612 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final C2611 f8762;

        /* renamed from: 㿎.ሽ.㿎.ඓ$㳳$ῲ  reason: contains not printable characters */
        /* compiled from: Http2Connection */
        public class C2599 extends AbstractRunnableC2561 {
            public C2599(String str, Object... objArr) {
                super(str, objArr);
            }

            @Override // 㿎.ሽ.AbstractRunnableC2561
            /* renamed from: K  reason: contains not printable characters */
            public void m6837() {
                C2591 r0 = C2591.this;
                r0.f8716.m6841(r0);
            }
        }

        /* renamed from: 㿎.ሽ.㿎.ඓ$㳳$K  reason: contains not printable characters */
        /* compiled from: Http2Connection */
        public class C2600 extends AbstractRunnableC2561 {

            /* renamed from: ʬ  reason: contains not printable characters */
            public final /* synthetic */ C2621 f8765;

            /* JADX INFO: super call moved to the top of the method (can break code semantics) */
            public C2600(String str, Object[] objArr, C2621 r4) {
                super(str, objArr);
                this.f8765 = r4;
            }

            @Override // 㿎.ሽ.AbstractRunnableC2561
            /* renamed from: K  reason: contains not printable characters */
            public void m6838() {
                try {
                    C2591.this.f8716.m6842(this.f8765);
                } catch (IOException e) {
                    C2558 r1 = C2558.f8643;
                    StringBuilder r3 = C1293.m3416("Http2Connection.Listener failure for ");
                    r3.append(C2591.this.f8721);
                    r1.m6731(4, r3.toString(), e);
                    try {
                        this.f8765.m6906(ErrorCode.PROTOCOL_ERROR);
                    } catch (IOException unused) {
                    }
                }
            }
        }

        public C2598(C2611 r4) {
            super("OkHttp %s", C2591.this.f8721);
            this.f8762 = r4;
        }

        /* renamed from: ῲ  reason: contains not printable characters */
        public void m6829() {
        }

        /* JADX WARNING: Code restructure failed: missing block: B:16:?, code lost:
            r1 = okhttp3.internal.http2.ErrorCode.PROTOCOL_ERROR;
            r0 = okhttp3.internal.http2.ErrorCode.PROTOCOL_ERROR;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:17:0x0020, code lost:
            r2 = r4.f8763;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:22:0x002b, code lost:
            r2 = th;
         */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x001c */
        @Override // 㿎.ሽ.AbstractRunnableC2561
        /* renamed from: K  reason: contains not printable characters */
        public void m6830() {
            ErrorCode errorCode;
            C2591 r2;
            ErrorCode errorCode2 = ErrorCode.INTERNAL_ERROR;
            try {
                this.f8762.m6881(this);
                while (this.f8762.m6883(false, (C2611.AbstractC2612) this)) {
                }
                errorCode = ErrorCode.NO_ERROR;
                errorCode2 = ErrorCode.CANCEL;
                try {
                    r2 = C2591.this;
                } catch (IOException unused) {
                }
            } catch (IOException unused2) {
                errorCode = errorCode2;
            } catch (Throwable th) {
                Throwable th2 = th;
                errorCode = errorCode2;
                try {
                    C2591.this.m6820(errorCode, errorCode2);
                } catch (IOException unused3) {
                }
                C2540.m6651(this.f8762);
                throw th2;
            }
            r2.m6820(errorCode, errorCode2);
            C2540.m6651(this.f8762);
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6831(int i, int i2, int i3, boolean z) {
        }

        /* JADX WARNING: Code restructure failed: missing block: B:27:0x0071, code lost:
            r0.m6905(r13);
         */
        /* JADX WARNING: Code restructure failed: missing block: B:28:0x0074, code lost:
            if (r10 == false) goto L_?;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:29:0x0076, code lost:
            r0.m6907();
         */
        /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost:
            return;
         */
        /* JADX WARNING: Code restructure failed: missing block: B:33:?, code lost:
            return;
         */
        /* renamed from: K  reason: contains not printable characters */
        public void m6835(boolean z, int i, int i2, List<C2614> list) {
            if (C2591.this.m6810(i)) {
                C2591.this.m6808(i, list, z);
                return;
            }
            synchronized (C2591.this) {
                try {
                    C2621 r0 = C2591.this.m6812(i);
                    if (r0 == null) {
                        if (!C2591.this.f8733) {
                            if (i > C2591.this.f8731) {
                                if (i % 2 != C2591.this.f8726 % 2) {
                                    C2621 r02 = new C2621(i, C2591.this, false, z, list);
                                    C2591.this.f8731 = i;
                                    C2591.this.f8732.put(Integer.valueOf(i), r02);
                                    C2591.f8715.execute(new C2600("OkHttp %s stream %d", new Object[]{C2591.this.f8721, Integer.valueOf(i)}, r02));
                                }
                            }
                        }
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6836(boolean z, C2615 r12) {
            int i;
            C2621[] r6;
            long j;
            int i2;
            synchronized (C2591.this) {
                int r1 = C2591.this.f8719.m6884();
                if (z) {
                    C2615 r11 = C2591.this.f8719;
                    r11.f8823 = 0;
                    Arrays.fill(r11.f8822, 0);
                }
                C2591.this.f8719.m6886(r12);
                try {
                    C2591.this.f8724.execute(new C2618(this, "OkHttp %s ACK Settings", new Object[]{C2591.this.f8721}, r12));
                } catch (RejectedExecutionException unused) {
                }
                int r122 = C2591.this.f8719.m6884();
                r6 = null;
                if (r122 == -1 || r122 == r1) {
                    j = 0;
                } else {
                    j = (long) (r122 - r1);
                    if (!C2591.this.f8722) {
                        C2591.this.f8722 = true;
                    }
                    if (!C2591.this.f8732.isEmpty()) {
                        r6 = (C2621[]) C2591.this.f8732.values().toArray(new C2621[C2591.this.f8732.size()]);
                    }
                }
                C2591.f8715.execute(new C2599("OkHttp %s settings", C2591.this.f8721));
            }
            if (!(r6 == null || j == 0)) {
                for (C2621 r0 : r6) {
                    synchronized (r0) {
                        r0.f8855 += j;
                        if (i2 > 0) {
                            r0.notifyAll();
                        }
                    }
                }
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6834(boolean z, int i, int i2) {
            if (z) {
                synchronized (C2591.this) {
                    C2591.this.f8727 = false;
                    C2591.this.notifyAll();
                }
                return;
            }
            try {
                C2591.this.f8724.execute(new C2594(true, i, i2));
            } catch (RejectedExecutionException unused) {
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6833(int i, ErrorCode errorCode, ByteString byteString) {
            C2621[] r6;
            byteString.size();
            synchronized (C2591.this) {
                r6 = (C2621[]) C2591.this.f8732.values().toArray(new C2621[C2591.this.f8732.size()]);
                C2591.this.f8733 = true;
            }
            for (C2621 r1 : r6) {
                if (r1.f8851 > i && r1.m6909()) {
                    r1.m6908(ErrorCode.REFUSED_STREAM);
                    C2591.this.m6805(r1.f8851);
                }
            }
        }

        /* renamed from: K  reason: contains not printable characters */
        public void m6832(int i, long j) {
            if (i == 0) {
                synchronized (C2591.this) {
                    C2591.this.f8717 += j;
                    C2591.this.notifyAll();
                }
                return;
            }
            C2621 r4 = C2591.this.m6812(i);
            if (r4 != null) {
                synchronized (r4) {
                    r4.f8855 += j;
                    if (j > 0) {
                        r4.notifyAll();
                    }
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6818(int i, boolean z, C1492 r11, long j) throws IOException {
        int min;
        long j2;
        if (j == 0) {
            this.f8720.m6860(z, i, r11, 0);
            return;
        }
        while (j > 0) {
            synchronized (this) {
                while (this.f8717 <= 0) {
                    try {
                        if (this.f8732.containsKey(Integer.valueOf(i))) {
                            wait();
                        } else {
                            throw new IOException("stream closed");
                        }
                    } catch (InterruptedException unused) {
                        Thread.currentThread().interrupt();
                        throw new InterruptedIOException();
                    }
                }
                min = Math.min((int) Math.min(j, this.f8717), this.f8720.f8778);
                j2 = (long) min;
                this.f8717 -= j2;
            }
            j -= j2;
            this.f8720.m6860(z && j == 0, i, r11, min);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6814(int i, long j) {
        try {
            this.f8724.execute(new C2595("OkHttp Window Update %s stream %d", new Object[]{this.f8721, Integer.valueOf(i)}, i, j));
        } catch (RejectedExecutionException unused) {
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6822(boolean z, int i, int i2) {
        boolean z2;
        if (!z) {
            synchronized (this) {
                z2 = this.f8727;
                this.f8727 = true;
            }
            if (z2) {
                m6807();
                return;
            }
        }
        try {
            this.f8720.m6858(z, i, i2);
        } catch (IOException unused) {
            m6807();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6819(ErrorCode errorCode) throws IOException {
        synchronized (this.f8720) {
            synchronized (this) {
                if (!this.f8733) {
                    this.f8733 = true;
                    this.f8720.m6856(this.f8731, errorCode, C2540.f8569);
                }
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6820(ErrorCode errorCode, ErrorCode errorCode2) throws IOException {
        IOException e;
        C2621[] r0 = null;
        try {
            m6819(errorCode);
            e = null;
        } catch (IOException e2) {
            e = e2;
        }
        synchronized (this) {
            if (!this.f8732.isEmpty()) {
                r0 = (C2621[]) this.f8732.values().toArray(new C2621[this.f8732.size()]);
                this.f8732.clear();
            }
        }
        if (r0 != null) {
            for (C2621 r3 : r0) {
                try {
                    r3.m6906(errorCode2);
                } catch (IOException e3) {
                    if (e != null) {
                        e = e3;
                    }
                }
            }
        }
        try {
            this.f8720.close();
        } catch (IOException e4) {
            if (e == null) {
                e = e4;
            }
        }
        try {
            this.f8729.close();
        } catch (IOException e5) {
            e = e5;
        }
        this.f8724.shutdown();
        this.f8730.shutdown();
        if (e != null) {
            throw e;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6815(int i, List<C2614> list) {
        synchronized (this) {
            if (this.f8718.contains(Integer.valueOf(i))) {
                m6809(i, ErrorCode.PROTOCOL_ERROR);
                return;
            }
            this.f8718.add(Integer.valueOf(i));
            try {
                m6821(new C2592("OkHttp %s Push Request[%s]", new Object[]{this.f8721, Integer.valueOf(i)}, i, list));
            } catch (RejectedExecutionException unused) {
            }
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6817(int i, AbstractC1496 r10, int i2, boolean z) throws IOException {
        C1492 r5 = new C1492();
        long j = (long) i2;
        r10.m3823(j);
        r10.read(r5, j);
        if (r5.f5529 == j) {
            m6821(new C2593("OkHttp %s Push Data[%s]", new Object[]{this.f8721, Integer.valueOf(i)}, i, r5, i2, z));
            return;
        }
        throw new IOException(r5.f5529 + " != " + i2);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m6816(int i, ErrorCode errorCode) {
        m6821(new C2601("OkHttp %s Push Reset[%s]", new Object[]{this.f8721, Integer.valueOf(i)}, i, errorCode));
    }

    /* renamed from: K  reason: contains not printable characters */
    public final synchronized void m6821(AbstractRunnableC2561 r2) {
        if (!m6823()) {
            this.f8730.execute(r2);
        }
    }
}
