Make sure that setAutoRead(false) has a direct effect and only update interestedOps if needed

This commit is contained in:
Norman Maurer 2013-05-24 12:49:21 +02:00
parent 252bd25855
commit d31ccebd62

View File

@ -50,8 +50,11 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
assert eventLoop().inEventLoop(); assert eventLoop().inEventLoop();
final SelectionKey key = selectionKey(); final SelectionKey key = selectionKey();
if (!config().isAutoRead()) { if (!config().isAutoRead()) {
// only remove readInterestOp if needed int interestOps = key.interestOps();
key.interestOps(key.interestOps() & ~readInterestOp); if ((interestOps & readInterestOp) != 0) {
// only remove readInterestOp if needed
key.interestOps(interestOps & ~readInterestOp);
}
} }
final ChannelPipeline pipeline = pipeline(); final ChannelPipeline pipeline = pipeline();
@ -73,9 +76,13 @@ public abstract class AbstractNioMessageChannel extends AbstractNioChannel {
closed = true; closed = true;
break loop; break loop;
} }
if (reads++ > READ_BATCH_SIZE) { if (reads++ > READ_BATCH_SIZE) {
break; break;
} }
if (!config().isAutoRead()) {
break loop;
}
} }
} catch (Throwable t) { } catch (Throwable t) {
if (read) { if (read) {