package io.netty.channel.epoll;

import g.a.a.a.a;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import io.netty.channel.AbstractChannel;
import io.netty.channel.Channel;
import io.netty.channel.ChannelConfig;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.ConnectTimeoutException;
import io.netty.channel.EventLoop;
import io.netty.channel.RecvByteBufAllocator;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import io.netty.channel.socket.ChannelInputShutdownReadComplete;
import io.netty.channel.socket.SocketChannelConfig;
import io.netty.channel.unix.Errors;
import io.netty.channel.unix.FileDescriptor;
import io.netty.channel.unix.Socket;
import io.netty.channel.unix.UnixChannel;
import io.netty.channel.unix.UnixChannelUtil;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.internal.ObjectUtil;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AlreadyConnectedException;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.ConnectionPendingException;
import java.nio.channels.NotYetConnectedException;
import java.nio.channels.UnresolvedAddressException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractEpollChannel extends AbstractChannel implements UnixChannel {
    private static final ClosedChannelException DO_CLOSE_CLOSED_CHANNEL_EXCEPTION = (ClosedChannelException) a.N(AbstractEpollChannel.class, "doClose()");
    private static final ChannelMetadata METADATA = new ChannelMetadata(false);
    public volatile boolean active;
    private ChannelPromise connectPromise;
    private ScheduledFuture<?> connectTimeoutFuture;
    public boolean epollInReadyRunnablePending;
    public int flags;
    public boolean inputClosedSeenErrorOnRead;
    private volatile SocketAddress local;
    private final int readFlag;
    private volatile SocketAddress remote;
    private SocketAddress requestedRemoteAddress;
    public final LinuxSocket socket;

    public abstract class AbstractEpollUnsafe extends AbstractChannel.AbstractUnsafe {
        public static final /* synthetic */ boolean $assertionsDisabled = false;
        private EpollRecvByteAllocatorHandle allocHandle;
        private final Runnable epollInReadyRunnable;
        public boolean maybeMoreDataToRead;
        public boolean readPending;

        public AbstractEpollUnsafe() {
            super();
            this.epollInReadyRunnable = new Runnable() { // from class: io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe.1
                @Override // java.lang.Runnable
                public void run() {
                    AbstractEpollUnsafe abstractEpollUnsafe = AbstractEpollUnsafe.this;
                    AbstractEpollChannel.this.epollInReadyRunnablePending = false;
                    abstractEpollUnsafe.epollInReady();
                }
            };
        }

        private void clearEpollRdHup() {
            try {
                AbstractEpollChannel.this.clearFlag(Native.EPOLLRDHUP);
            } catch (IOException e2) {
                AbstractEpollChannel.this.pipeline().fireExceptionCaught((Throwable) e2);
                close(voidPromise());
            }
        }

        private boolean doFinishConnect() {
            if (!AbstractEpollChannel.this.socket.finishConnect()) {
                AbstractEpollChannel.this.setFlag(Native.EPOLLOUT);
                return false;
            }
            AbstractEpollChannel.this.clearFlag(Native.EPOLLOUT);
            if (AbstractEpollChannel.this.requestedRemoteAddress instanceof InetSocketAddress) {
                AbstractEpollChannel abstractEpollChannel = AbstractEpollChannel.this;
                abstractEpollChannel.remote = UnixChannelUtil.computeRemoteAddr((InetSocketAddress) abstractEpollChannel.requestedRemoteAddress, AbstractEpollChannel.this.socket.remoteAddress());
            }
            AbstractEpollChannel.this.requestedRemoteAddress = null;
            return true;
        }

        private void finishConnect() {
            boolean zIsActive;
            try {
                zIsActive = AbstractEpollChannel.this.isActive();
            } catch (Throwable th) {
                try {
                    fulfillConnectPromise(AbstractEpollChannel.this.connectPromise, annotateConnectException(th, AbstractEpollChannel.this.requestedRemoteAddress));
                    if (AbstractEpollChannel.this.connectTimeoutFuture != null) {
                    }
                } finally {
                    if (AbstractEpollChannel.this.connectTimeoutFuture != null) {
                        AbstractEpollChannel.this.connectTimeoutFuture.cancel(false);
                    }
                    AbstractEpollChannel.this.connectPromise = null;
                }
            }
            if (doFinishConnect()) {
                fulfillConnectPromise(AbstractEpollChannel.this.connectPromise, zIsActive);
            }
        }

        private void fireEventAndClose(Object obj) {
            AbstractEpollChannel.this.pipeline().fireUserEventTriggered(obj);
            close(voidPromise());
        }

        private void fulfillConnectPromise(ChannelPromise channelPromise, Throwable th) {
            if (channelPromise == null) {
                return;
            }
            channelPromise.tryFailure(th);
            closeIfClosed();
        }

        private void fulfillConnectPromise(ChannelPromise channelPromise, boolean z2) {
            if (channelPromise == null) {
                return;
            }
            AbstractEpollChannel.this.active = true;
            boolean zIsActive = AbstractEpollChannel.this.isActive();
            boolean zTrySuccess = channelPromise.trySuccess();
            if (!z2 && zIsActive) {
                AbstractEpollChannel.this.pipeline().fireChannelActive();
            }
            if (zTrySuccess) {
                return;
            }
            close(voidPromise());
        }

        public final void clearEpollIn0() {
            try {
                this.readPending = false;
                AbstractEpollChannel abstractEpollChannel = AbstractEpollChannel.this;
                abstractEpollChannel.clearFlag(abstractEpollChannel.readFlag);
            } catch (IOException e2) {
                AbstractEpollChannel.this.pipeline().fireExceptionCaught((Throwable) e2);
                AbstractEpollChannel.this.unsafe().close(AbstractEpollChannel.this.unsafe().voidPromise());
            }
        }

        @Override // io.netty.channel.Channel.Unsafe
        public void connect(final SocketAddress socketAddress, SocketAddress socketAddress2, ChannelPromise channelPromise) {
            if (channelPromise.setUncancellable() && ensureOpen(channelPromise)) {
                try {
                    if (AbstractEpollChannel.this.connectPromise != null) {
                        throw new ConnectionPendingException();
                    }
                    boolean zIsActive = AbstractEpollChannel.this.isActive();
                    if (AbstractEpollChannel.this.doConnect(socketAddress, socketAddress2)) {
                        fulfillConnectPromise(channelPromise, zIsActive);
                        return;
                    }
                    AbstractEpollChannel.this.connectPromise = channelPromise;
                    AbstractEpollChannel.this.requestedRemoteAddress = socketAddress;
                    int connectTimeoutMillis = AbstractEpollChannel.this.config().getConnectTimeoutMillis();
                    if (connectTimeoutMillis > 0) {
                        AbstractEpollChannel abstractEpollChannel = AbstractEpollChannel.this;
                        abstractEpollChannel.connectTimeoutFuture = abstractEpollChannel.eventLoop().schedule(new Runnable() { // from class: io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe.2
                            @Override // java.lang.Runnable
                            public void run() {
                                ChannelPromise channelPromise2 = AbstractEpollChannel.this.connectPromise;
                                StringBuilder sbF = a.F("connection timed out: ");
                                sbF.append(socketAddress);
                                ConnectTimeoutException connectTimeoutException = new ConnectTimeoutException(sbF.toString());
                                if (channelPromise2 == null || !channelPromise2.tryFailure(connectTimeoutException)) {
                                    return;
                                }
                                AbstractEpollUnsafe abstractEpollUnsafe = AbstractEpollUnsafe.this;
                                abstractEpollUnsafe.close(abstractEpollUnsafe.voidPromise());
                            }
                        }, connectTimeoutMillis, TimeUnit.MILLISECONDS);
                    }
                    channelPromise.addListener((GenericFutureListener<? extends Future<? super Void>>) new ChannelFutureListener() { // from class: io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe.3
                        @Override // io.netty.util.concurrent.GenericFutureListener
                        public void operationComplete(ChannelFuture channelFuture) {
                            if (channelFuture.isCancelled()) {
                                if (AbstractEpollChannel.this.connectTimeoutFuture != null) {
                                    AbstractEpollChannel.this.connectTimeoutFuture.cancel(false);
                                }
                                AbstractEpollChannel.this.connectPromise = null;
                                AbstractEpollUnsafe abstractEpollUnsafe = AbstractEpollUnsafe.this;
                                abstractEpollUnsafe.close(abstractEpollUnsafe.voidPromise());
                            }
                        }
                    });
                } catch (Throwable th) {
                    closeIfClosed();
                    channelPromise.tryFailure(annotateConnectException(th, socketAddress));
                }
            }
        }

        public final void epollInBefore() {
            this.maybeMoreDataToRead = false;
        }

        public final void epollInFinally(ChannelConfig channelConfig) {
            this.maybeMoreDataToRead = this.allocHandle.isEdgeTriggered() && this.allocHandle.maybeMoreDataToRead();
            if (!this.readPending && !channelConfig.isAutoRead()) {
                AbstractEpollChannel.this.clearEpollIn();
            } else if (this.readPending && this.maybeMoreDataToRead) {
                executeEpollInReadyRunnable(channelConfig);
            }
        }

        public abstract void epollInReady();

        public final void epollOutReady() {
            if (AbstractEpollChannel.this.connectPromise != null) {
                finishConnect();
            } else {
                if (AbstractEpollChannel.this.socket.isOutputShutdown()) {
                    return;
                }
                super.flush0();
            }
        }

        public final void epollRdHupReady() {
            recvBufAllocHandle().receivedRdHup();
            if (AbstractEpollChannel.this.isActive()) {
                epollInReady();
            } else {
                shutdownInput(true);
            }
            clearEpollRdHup();
        }

        public final void executeEpollInReadyRunnable(ChannelConfig channelConfig) {
            AbstractEpollChannel abstractEpollChannel = AbstractEpollChannel.this;
            if (abstractEpollChannel.epollInReadyRunnablePending || !abstractEpollChannel.isActive() || AbstractEpollChannel.this.shouldBreakEpollInReady(channelConfig)) {
                return;
            }
            AbstractEpollChannel abstractEpollChannel2 = AbstractEpollChannel.this;
            abstractEpollChannel2.epollInReadyRunnablePending = true;
            abstractEpollChannel2.eventLoop().execute(this.epollInReadyRunnable);
        }

        @Override // io.netty.channel.AbstractChannel.AbstractUnsafe
        public final void flush0() {
            if (AbstractEpollChannel.this.isFlagSet(Native.EPOLLOUT)) {
                return;
            }
            super.flush0();
        }

        public EpollRecvByteAllocatorHandle newEpollHandle(RecvByteBufAllocator.ExtendedHandle extendedHandle) {
            return new EpollRecvByteAllocatorHandle(extendedHandle);
        }

        @Override // io.netty.channel.AbstractChannel.AbstractUnsafe, io.netty.channel.Channel.Unsafe
        public EpollRecvByteAllocatorHandle recvBufAllocHandle() {
            if (this.allocHandle == null) {
                this.allocHandle = newEpollHandle((RecvByteBufAllocator.ExtendedHandle) super.recvBufAllocHandle());
            }
            return this.allocHandle;
        }

        public void shutdownInput(boolean z2) {
            ChannelPipeline channelPipelinePipeline;
            Object obj;
            if (AbstractEpollChannel.this.socket.isInputShutdown()) {
                if (z2) {
                    return;
                }
                AbstractEpollChannel abstractEpollChannel = AbstractEpollChannel.this;
                abstractEpollChannel.inputClosedSeenErrorOnRead = true;
                channelPipelinePipeline = abstractEpollChannel.pipeline();
                obj = ChannelInputShutdownReadComplete.INSTANCE;
            } else {
                if (!AbstractEpollChannel.isAllowHalfClosure(AbstractEpollChannel.this.config())) {
                    close(voidPromise());
                    return;
                }
                try {
                    AbstractEpollChannel.this.socket.shutdown(true, false);
                } catch (IOException unused) {
                    fireEventAndClose(ChannelInputShutdownEvent.INSTANCE);
                    return;
                } catch (NotYetConnectedException unused2) {
                }
                AbstractEpollChannel.this.clearEpollIn();
                channelPipelinePipeline = AbstractEpollChannel.this.pipeline();
                obj = ChannelInputShutdownEvent.INSTANCE;
            }
            channelPipelinePipeline.fireUserEventTriggered(obj);
        }
    }

    public AbstractEpollChannel(Channel channel, LinuxSocket linuxSocket, int i2, SocketAddress socketAddress) {
        super(channel);
        this.flags = Native.EPOLLET;
        this.socket = (LinuxSocket) ObjectUtil.checkNotNull(linuxSocket, "fd");
        this.readFlag = i2;
        this.flags |= i2;
        this.active = true;
        this.remote = socketAddress;
        this.local = linuxSocket.localAddress();
    }

    public AbstractEpollChannel(Channel channel, LinuxSocket linuxSocket, int i2, boolean z2) {
        super(channel);
        this.flags = Native.EPOLLET;
        this.socket = (LinuxSocket) ObjectUtil.checkNotNull(linuxSocket, "fd");
        this.readFlag = i2;
        this.flags |= i2;
        this.active = z2;
        if (z2) {
            this.local = linuxSocket.localAddress();
            this.remote = linuxSocket.remoteAddress();
        }
    }

    public AbstractEpollChannel(LinuxSocket linuxSocket, int i2) {
        this((Channel) null, linuxSocket, i2, false);
    }

    public static void checkResolvable(InetSocketAddress inetSocketAddress) {
        if (inetSocketAddress.isUnresolved()) {
            throw new UnresolvedAddressException();
        }
    }

    private boolean doConnect0(SocketAddress socketAddress) throws Errors.NativeIoException {
        try {
            boolean zConnect = this.socket.connect(socketAddress);
            if (!zConnect) {
                setFlag(Native.EPOLLOUT);
            }
            return zConnect;
        } catch (Throwable th) {
            doClose();
            throw th;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static boolean isAllowHalfClosure(ChannelConfig channelConfig) {
        return (channelConfig instanceof SocketChannelConfig) && ((SocketChannelConfig) channelConfig).isAllowHalfClosure();
    }

    public static boolean isSoErrorZero(Socket socket) {
        try {
            return socket.getSoError() == 0;
        } catch (IOException e2) {
            throw new ChannelException(e2);
        }
    }

    private void modifyEvents() {
        if (isOpen() && isRegistered()) {
            ((EpollEventLoop) eventLoop()).modify(this);
        }
    }

    private static ByteBuf newDirectBuffer0(Object obj, ByteBuf byteBuf, ByteBufAllocator byteBufAllocator, int i2) {
        ByteBuf byteBufDirectBuffer = byteBufAllocator.directBuffer(i2);
        byteBufDirectBuffer.writeBytes(byteBuf, byteBuf.readerIndex(), i2);
        ReferenceCountUtil.safeRelease(obj);
        return byteBufDirectBuffer;
    }

    public final void clearEpollIn() {
        if (!isRegistered()) {
            this.flags &= ~this.readFlag;
            return;
        }
        EventLoop eventLoop = eventLoop();
        final AbstractEpollUnsafe abstractEpollUnsafe = (AbstractEpollUnsafe) unsafe();
        if (eventLoop.inEventLoop()) {
            abstractEpollUnsafe.clearEpollIn0();
        } else {
            eventLoop.execute(new Runnable() { // from class: io.netty.channel.epoll.AbstractEpollChannel.2
                @Override // java.lang.Runnable
                public void run() {
                    if (abstractEpollUnsafe.readPending || AbstractEpollChannel.this.config().isAutoRead()) {
                        return;
                    }
                    abstractEpollUnsafe.clearEpollIn0();
                }
            });
        }
    }

    public void clearFlag(int i2) {
        if (isFlagSet(i2)) {
            this.flags = (~i2) & this.flags;
            modifyEvents();
        }
    }

    @Override // io.netty.channel.Channel
    public abstract EpollChannelConfig config();

    @Override // io.netty.channel.AbstractChannel
    public final void doBeginRead() {
        AbstractEpollUnsafe abstractEpollUnsafe = (AbstractEpollUnsafe) unsafe();
        abstractEpollUnsafe.readPending = true;
        setFlag(this.readFlag);
        if (abstractEpollUnsafe.maybeMoreDataToRead) {
            abstractEpollUnsafe.executeEpollInReadyRunnable(config());
        }
    }

    @Override // io.netty.channel.AbstractChannel
    public void doBind(SocketAddress socketAddress) {
        if (socketAddress instanceof InetSocketAddress) {
            checkResolvable((InetSocketAddress) socketAddress);
        }
        this.socket.bind(socketAddress);
        this.local = this.socket.localAddress();
    }

    @Override // io.netty.channel.AbstractChannel
    public void doClose() throws Errors.NativeIoException {
        this.active = false;
        this.inputClosedSeenErrorOnRead = true;
        try {
            ChannelPromise channelPromise = this.connectPromise;
            if (channelPromise != null) {
                channelPromise.tryFailure(DO_CLOSE_CLOSED_CHANNEL_EXCEPTION);
                this.connectPromise = null;
            }
            ScheduledFuture<?> scheduledFuture = this.connectTimeoutFuture;
            if (scheduledFuture != null) {
                scheduledFuture.cancel(false);
                this.connectTimeoutFuture = null;
            }
            if (isRegistered()) {
                EventLoop eventLoop = eventLoop();
                if (eventLoop.inEventLoop()) {
                    doDeregister();
                } else {
                    eventLoop.execute(new Runnable() { // from class: io.netty.channel.epoll.AbstractEpollChannel.1
                        @Override // java.lang.Runnable
                        public void run() {
                            try {
                                AbstractEpollChannel.this.doDeregister();
                            } catch (Throwable th) {
                                AbstractEpollChannel.this.pipeline().fireExceptionCaught(th);
                            }
                        }
                    });
                }
            }
        } finally {
            this.socket.close();
        }
    }

    public boolean doConnect(SocketAddress socketAddress, SocketAddress socketAddress2) throws Errors.NativeIoException {
        if (socketAddress2 instanceof InetSocketAddress) {
            checkResolvable((InetSocketAddress) socketAddress2);
        }
        InetSocketAddress inetSocketAddress = socketAddress instanceof InetSocketAddress ? (InetSocketAddress) socketAddress : null;
        if (inetSocketAddress != null) {
            checkResolvable(inetSocketAddress);
        }
        if (this.remote != null) {
            throw new AlreadyConnectedException();
        }
        if (socketAddress2 != null) {
            this.socket.bind(socketAddress2);
        }
        boolean zDoConnect0 = doConnect0(socketAddress);
        if (zDoConnect0) {
            if (inetSocketAddress != null) {
                socketAddress = UnixChannelUtil.computeRemoteAddr(inetSocketAddress, this.socket.remoteAddress());
            }
            this.remote = socketAddress;
        }
        this.local = this.socket.localAddress();
        return zDoConnect0;
    }

    @Override // io.netty.channel.AbstractChannel
    public void doDeregister() {
        ((EpollEventLoop) eventLoop()).remove(this);
    }

    @Override // io.netty.channel.AbstractChannel
    public void doDisconnect() throws Errors.NativeIoException {
        doClose();
    }

    public final int doReadBytes(ByteBuf byteBuf) {
        int address;
        int iWriterIndex = byteBuf.writerIndex();
        unsafe().recvBufAllocHandle().attemptedBytesRead(byteBuf.writableBytes());
        if (byteBuf.hasMemoryAddress()) {
            address = this.socket.readAddress(byteBuf.memoryAddress(), iWriterIndex, byteBuf.capacity());
        } else {
            ByteBuffer byteBufferInternalNioBuffer = byteBuf.internalNioBuffer(iWriterIndex, byteBuf.writableBytes());
            address = this.socket.read(byteBufferInternalNioBuffer, byteBufferInternalNioBuffer.position(), byteBufferInternalNioBuffer.limit());
        }
        if (address > 0) {
            byteBuf.writerIndex(iWriterIndex + address);
        }
        return address;
    }

    @Override // io.netty.channel.AbstractChannel
    public void doRegister() {
        this.epollInReadyRunnablePending = false;
        ((EpollEventLoop) eventLoop()).add(this);
    }

    public final int doWriteBytes(ChannelOutboundBuffer channelOutboundBuffer, ByteBuf byteBuf) {
        long j2;
        if (byteBuf.hasMemoryAddress()) {
            int iWriteAddress = this.socket.writeAddress(byteBuf.memoryAddress(), byteBuf.readerIndex(), byteBuf.writerIndex());
            if (iWriteAddress <= 0) {
                return Integer.MAX_VALUE;
            }
            j2 = iWriteAddress;
        } else {
            ByteBuffer byteBufferInternalNioBuffer = byteBuf.nioBufferCount() == 1 ? byteBuf.internalNioBuffer(byteBuf.readerIndex(), byteBuf.readableBytes()) : byteBuf.nioBuffer();
            int iWrite = this.socket.write(byteBufferInternalNioBuffer, byteBufferInternalNioBuffer.position(), byteBufferInternalNioBuffer.limit());
            if (iWrite <= 0) {
                return Integer.MAX_VALUE;
            }
            byteBufferInternalNioBuffer.position(byteBufferInternalNioBuffer.position() + iWrite);
            j2 = iWrite;
        }
        channelOutboundBuffer.removeBytes(j2);
        return 1;
    }

    @Override // io.netty.channel.unix.UnixChannel
    public final FileDescriptor fd() {
        return this.socket;
    }

    @Override // io.netty.channel.Channel
    public boolean isActive() {
        return this.active;
    }

    @Override // io.netty.channel.AbstractChannel
    public boolean isCompatible(EventLoop eventLoop) {
        return eventLoop instanceof EpollEventLoop;
    }

    public boolean isFlagSet(int i2) {
        return (i2 & this.flags) != 0;
    }

    @Override // io.netty.channel.Channel
    public boolean isOpen() {
        return this.socket.isOpen();
    }

    @Override // io.netty.channel.AbstractChannel
    public SocketAddress localAddress0() {
        return this.local;
    }

    @Override // io.netty.channel.Channel
    public ChannelMetadata metadata() {
        return METADATA;
    }

    public final ByteBuf newDirectBuffer(ByteBuf byteBuf) {
        return newDirectBuffer(byteBuf, byteBuf);
    }

    public final ByteBuf newDirectBuffer(Object obj, ByteBuf byteBuf) {
        ByteBuf byteBufThreadLocalDirectBuffer;
        int i2 = byteBuf.readableBytes();
        if (i2 == 0) {
            ReferenceCountUtil.release(obj);
            return Unpooled.EMPTY_BUFFER;
        }
        ByteBufAllocator byteBufAllocatorAlloc = alloc();
        if (!byteBufAllocatorAlloc.isDirectBufferPooled() && (byteBufThreadLocalDirectBuffer = ByteBufUtil.threadLocalDirectBuffer()) != null) {
            byteBufThreadLocalDirectBuffer.writeBytes(byteBuf, byteBuf.readerIndex(), i2);
            ReferenceCountUtil.safeRelease(obj);
            return byteBufThreadLocalDirectBuffer;
        }
        return newDirectBuffer0(obj, byteBuf, byteBufAllocatorAlloc, i2);
    }

    @Override // io.netty.channel.AbstractChannel
    public abstract AbstractEpollUnsafe newUnsafe();

    @Override // io.netty.channel.AbstractChannel
    public SocketAddress remoteAddress0() {
        return this.remote;
    }

    public void setFlag(int i2) {
        if (isFlagSet(i2)) {
            return;
        }
        this.flags = i2 | this.flags;
        modifyEvents();
    }

    public final boolean shouldBreakEpollInReady(ChannelConfig channelConfig) {
        return this.socket.isInputShutdown() && (this.inputClosedSeenErrorOnRead || !isAllowHalfClosure(channelConfig));
    }
}
