* Fix issue #422

It's an regression for #280, the sharedBufferList may leak to async path.

* Do check for DefaultChannelConfiguration.WriteBufferHighWaterMark when set

* Also check whether IncompleteWrite finish in sync for AbstractSocketByteChannel.

Otherwise may not all flushed buffer will be writen before next flush

* Invalid nio buffer cache for partial writen
This commit is contained in:
SilverFox 2018-10-06 07:30:22 +08:00 коммит произвёл Max Gortman
Родитель 30a1aefba1
Коммит b5450a4647
4 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -309,6 +309,10 @@ namespace DotNetty.Transport.Channels
// readableBytes > writtenBytes // readableBytes > writtenBytes
if (writtenBytes != 0) if (writtenBytes != 0)
{ {
//Invalid nio buffer cache for partial writen, see https://github.com/Azure/DotNetty/issues/422
this.flushedEntry.Buffer = new ArraySegment<byte>();
this.flushedEntry.Buffers = null;
buf.SetReaderIndex(readerIndex + (int)writtenBytes); buf.SetReaderIndex(readerIndex + (int)writtenBytes);
this.Progress(writtenBytes); this.Progress(writtenBytes);
} }

Просмотреть файл

@ -118,7 +118,7 @@ namespace DotNetty.Transport.Channels
} }
else if (ChannelOption.WriteBufferHighWaterMark.Equals(option)) else if (ChannelOption.WriteBufferHighWaterMark.Equals(option))
{ {
this.writeBufferHighWaterMark = (int)(object)value; this.WriteBufferHighWaterMark = (int)(object)value;
} }
else if (ChannelOption.WriteBufferLowWaterMark.Equals(option)) else if (ChannelOption.WriteBufferLowWaterMark.Equals(option))
{ {

Просмотреть файл

@ -231,9 +231,8 @@ namespace DotNetty.Transport.Channels.Sockets
{ {
input.Remove(); input.Remove();
} }
else else if (this.IncompleteWrite(scheduleAsync, this.PrepareWriteOperation(buf.GetIoBuffer())))
{ {
this.IncompleteWrite(scheduleAsync, this.PrepareWriteOperation(buf.GetIoBuffer()));
break; break;
} }
} /*else if (msg is FileRegion) { todo: FileRegion support } /*else if (msg is FileRegion) { todo: FileRegion support

Просмотреть файл

@ -316,7 +316,12 @@ namespace DotNetty.Transport.Channels.Sockets
if (!done) if (!done)
{ {
SocketChannelAsyncOperation asyncOperation = this.PrepareWriteOperation(bufferList); IList<ArraySegment<byte>> asyncBufferList = bufferList;
if (object.ReferenceEquals(sharedBufferList, asyncBufferList))
{
asyncBufferList = sharedBufferList.ToArray(); // copying buffers to
}
SocketChannelAsyncOperation asyncOperation = this.PrepareWriteOperation(asyncBufferList);
// Did not write all buffers completely. // Did not write all buffers completely.
if (this.IncompleteWrite(true, asyncOperation)) if (this.IncompleteWrite(true, asyncOperation))