Make sure OP_WRITE is correctly cleared when using FileRegion and other NioTasks
This commit is contained in:
parent
c03179c81c
commit
4505e7f1b3
@ -134,12 +134,6 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
protected void doFlushByteBuffer(ByteBuf buf) throws Exception {
|
||||||
if (!buf.isReadable()) {
|
|
||||||
// Reset reader/writerIndex to 0 if the buffer is empty.
|
|
||||||
buf.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -458,17 +458,15 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void processWritable(SelectionKey k, AbstractNioChannel ch) {
|
private static void processWritable(SelectionKey k, AbstractNioChannel ch) {
|
||||||
if (ch.writableTasks.isEmpty()) {
|
|
||||||
ch.unsafe().flushNow();
|
|
||||||
} else {
|
|
||||||
NioTask<SelectableChannel> task;
|
NioTask<SelectableChannel> task;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
task = ch.writableTasks.poll();
|
task = ch.writableTasks.poll();
|
||||||
if (task == null) { break; }
|
if (task == null) { break; }
|
||||||
processSelectedKey(ch.selectionKey(), task);
|
processSelectedKey(ch.selectionKey(), task);
|
||||||
}
|
}
|
||||||
k.interestOps(k.interestOps() | SelectionKey.OP_WRITE);
|
|
||||||
}
|
// Call flushNow which will also take care of clear the OP_WRITE once there is nothing left to write
|
||||||
|
ch.unsafe().flushNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unregisterWritableTasks(AbstractNioChannel ch) {
|
private static void unregisterWritableTasks(AbstractNioChannel ch) {
|
||||||
|
Loading…
Reference in New Issue
Block a user