Make sure writing empty ByteBuf will not cause a stavation.

This also fixes [#1436]
This commit is contained in:
Norman Maurer 2013-06-10 20:54:17 +02:00
parent b1b1a906f0
commit f2f6d68d2e

View File

@ -125,6 +125,10 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
if (msg instanceof ByteBuf) { if (msg instanceof ByteBuf) {
ByteBuf buf = (ByteBuf) msg; ByteBuf buf = (ByteBuf) msg;
if (!buf.isReadable()) {
buf.release();
return 1;
}
boolean done = false; boolean done = false;
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);