diff --git a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java index edee9347ee..81e22eb3aa 100755 --- a/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/aio/AioSocketChannel.java @@ -325,6 +325,10 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne inDoBeginRead = true; try { for (;;) { + if (inputShutdown) { + break; + } + ByteBuf byteBuf = pipeline().inboundByteBuffer(); if (!byteBuf.readable()) { byteBuf.discardReadBytes(); @@ -468,16 +472,16 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne pipeline.fireInboundBufferUpdated(); } - firedInboundBufferSuspended = true; - pipeline.fireInboundBufferSuspended(); + if (!closed && channel.isOpen()) { + firedInboundBufferSuspended = true; + pipeline.fireInboundBufferSuspended(); + } + pipeline.fireExceptionCaught(t); } finally { if (read) { pipeline.fireInboundBufferUpdated(); } - if (!firedInboundBufferSuspended) { - pipeline.fireInboundBufferSuspended(); - } // Double check because fireInboundBufferUpdated() might have triggered the closure by a user handler. if (closed || !channel.isOpen()) { @@ -489,6 +493,8 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne channel.unsafe().close(channel.unsafe().voidFuture()); } } + } else if (!firedInboundBufferSuspended) { + pipeline.fireInboundBufferSuspended(); } } }