Make sure OP_WRITE is correctly cleared when using FileRegion and other NioTasks

This commit is contained in:
Norman Maurer 2013-04-04 08:38:58 +02:00
parent c03179c81c
commit 4505e7f1b3
2 changed files with 8 additions and 16 deletions

View File

@ -134,12 +134,6 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
@Override
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 --) {
int localFlushedAmount = doWriteBytes(buf, i == 0);
if (localFlushedAmount > 0) {

View File

@ -458,17 +458,15 @@ public final class NioEventLoop extends SingleThreadEventLoop {
}
private static void processWritable(SelectionKey k, AbstractNioChannel ch) {
if (ch.writableTasks.isEmpty()) {
ch.unsafe().flushNow();
} else {
NioTask<SelectableChannel> task;
for (;;) {
task = ch.writableTasks.poll();
if (task == null) { break; }
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) {