Better handle blocks not taken taken from slabs
- If the block needs to be larger than 4032 bytes it won't be backed by a slab
This commit is contained in:
parent
412d527d01
commit
7c27c5c0e7
|
|
@ -18,7 +18,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
|
||||||
public class SocketInputStream : Stream
|
public class SocketInputStream : Stream
|
||||||
{
|
{
|
||||||
private static Task _emptyTask = Task.FromResult<object>(null);
|
private static Task _emptyTask = Task.FromResult<object>(null);
|
||||||
private static byte[] _emptyBuffer = new byte[0];
|
|
||||||
|
|
||||||
private readonly SocketInput _socketInput;
|
private readonly SocketInput _socketInput;
|
||||||
|
|
||||||
|
|
@ -91,8 +90,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Filter
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
// Close _socketInput with a 0-length write.
|
// Close _socketInput with a fake zero-length write that will result in a zero-length read.
|
||||||
Write(_emptyBuffer, 0, 0);
|
_socketInput.IncomingComplete(0, error: null);
|
||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
// Unpin may called without an earlier Pin
|
// Unpin may called without an earlier Pin
|
||||||
if (_pinned != null)
|
if (_pinned != null)
|
||||||
{
|
{
|
||||||
|
_pinned.Unpin();
|
||||||
|
|
||||||
_pinned.End += count;
|
_pinned.End += count;
|
||||||
if (_head == null)
|
if (_head == null)
|
||||||
{
|
{
|
||||||
|
|
@ -170,7 +172,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
|
||||||
{
|
{
|
||||||
var returnBlock = returnStart;
|
var returnBlock = returnStart;
|
||||||
returnStart = returnStart.Next;
|
returnStart = returnStart.Next;
|
||||||
returnBlock.Pool.Return(returnBlock);
|
returnBlock.Pool?.Return(returnBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,15 +130,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MemoryPoolBlock2 Create(int size, MemoryPool2 pool)
|
|
||||||
{
|
|
||||||
return new MemoryPoolBlock2
|
|
||||||
{
|
|
||||||
Data = new ArraySegment<byte>(new byte[size]),
|
|
||||||
Pool = pool
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MemoryPoolBlock2 Create(
|
public static MemoryPoolBlock2 Create(
|
||||||
ArraySegment<byte> data,
|
ArraySegment<byte> data,
|
||||||
IntPtr dataPtr,
|
IntPtr dataPtr,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue