No need to clear buffer as it is cleared later anyway and only update interestedOps if needed
This commit is contained in:
parent
d31ccebd62
commit
f5dc482a59
@ -55,8 +55,11 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
|||||||
assert eventLoop().inEventLoop();
|
assert eventLoop().inEventLoop();
|
||||||
final SelectionKey key = selectionKey();
|
final SelectionKey key = selectionKey();
|
||||||
if (!config().isAutoRead()) {
|
if (!config().isAutoRead()) {
|
||||||
|
int interestOps = key.interestOps();
|
||||||
|
if ((interestOps & readInterestOp) != 0) {
|
||||||
// only remove readInterestOp if needed
|
// only remove readInterestOp if needed
|
||||||
key.interestOps(key.interestOps() & ~readInterestOp);
|
key.interestOps(interestOps & ~readInterestOp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ChannelPipeline pipeline = pipeline();
|
final ChannelPipeline pipeline = pipeline();
|
||||||
@ -139,12 +142,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
|||||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||||
for (int i = config().getWriteSpinCount() - 1; i >= 0; i --) {
|
for (int i = config().getWriteSpinCount() - 1; i >= 0; i --) {
|
||||||
int localFlushedAmount = doWriteBytes(buf, i == 0);
|
int localFlushedAmount = doWriteBytes(buf, i == 0);
|
||||||
if (localFlushedAmount > 0) {
|
if (localFlushedAmount > 0 || !buf.isReadable()) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!buf.isReadable()) {
|
|
||||||
// Reset reader/writerIndex to 0 if the buffer is empty.
|
|
||||||
buf.clear();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user