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.NioServerSocketChannel;
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 java.util.ArrayList;

View File

@ -493,7 +493,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
channel.unsafe().close(channel.unsafe().voidFuture());
}
}
} else if (!firedInboundBufferSuspended) {
} else if (!firedInboundBufferSuspended) {
pipeline.fireInboundBufferSuspended();
}
}

View File

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

View File

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