Fix a bug in NIO transport where inboundBufferSuspended() is triggered even if the channel is closed.

- No non-static wildcard import
This commit is contained in:
Trustin Lee 2013-01-01 00:35:44 +09:00
parent 93fd73fbbf
commit 89a16fe01e
4 changed files with 24 additions and 20 deletions

View File

@ -29,7 +29,12 @@ import io.netty.channel.socket.nio.NioSctpChannel;
import io.netty.channel.socket.nio.NioSctpServerChannel; import io.netty.channel.socket.nio.NioSctpServerChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.socket.oio.*; import io.netty.channel.socket.oio.OioDatagramChannel;
import io.netty.channel.socket.oio.OioEventLoopGroup;
import io.netty.channel.socket.oio.OioSctpChannel;
import io.netty.channel.socket.oio.OioSctpServerChannel;
import io.netty.channel.socket.oio.OioServerSocketChannel;
import io.netty.channel.socket.oio.OioSocketChannel;
import io.netty.testsuite.util.TestUtils; import io.netty.testsuite.util.TestUtils;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -17,11 +17,11 @@ package io.netty.channel.socket.nio;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelPromise;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.channel.ChannelPromise;
import io.netty.channel.FileRegion; import io.netty.channel.FileRegion;
import io.netty.channel.socket.ChannelInputShutdownEvent;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.ClosedChannelException; import java.nio.channels.ClosedChannelException;
@ -100,20 +100,17 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
pipeline.fireInboundBufferUpdated(); pipeline.fireInboundBufferUpdated();
} }
if (t instanceof IOException) {
closed = true;
} else if (!closed) {
firedInboundBufferSuspended = true; firedInboundBufferSuspended = true;
pipeline.fireInboundBufferSuspended(); pipeline.fireInboundBufferSuspended();
pipeline().fireExceptionCaught(t);
if (t instanceof IOException) {
close(voidFuture());
} }
pipeline().fireExceptionCaught(t);
} finally { } finally {
if (read) { if (read) {
pipeline.fireInboundBufferUpdated(); pipeline.fireInboundBufferUpdated();
} }
if (!firedInboundBufferSuspended) {
pipeline.fireInboundBufferSuspended();
}
if (closed) { if (closed) {
setInputShutdown(); setInputShutdown();
@ -124,6 +121,8 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
close(voidFuture()); close(voidFuture());
} }
} }
} else if (!firedInboundBufferSuspended) {
pipeline.fireInboundBufferSuspended();
} }
} }
} }

View File

@ -71,22 +71,22 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
pipeline.fireInboundBufferUpdated(); pipeline.fireInboundBufferUpdated();
} }
if (t instanceof IOException) {
closed = true;
} else if (!closed) {
firedInboundBufferSuspended = true; firedInboundBufferSuspended = true;
pipeline.fireInboundBufferSuspended(); pipeline.fireInboundBufferSuspended();
}
pipeline().fireExceptionCaught(t); pipeline().fireExceptionCaught(t);
if (t instanceof IOException) {
close(voidFuture());
}
} finally { } finally {
if (read) { if (read) {
pipeline.fireInboundBufferUpdated(); pipeline.fireInboundBufferUpdated();
} }
if (!firedInboundBufferSuspended) {
pipeline.fireInboundBufferSuspended();
}
if (closed && isOpen()) { if (closed && isOpen()) {
close(voidFuture()); close(voidFuture());
} else if (!firedInboundBufferSuspended) {
pipeline.fireInboundBufferSuspended();
} }
} }
} }