One-time-use allocated blocks keep reference to source pool / Assert that a block is returned to it's source pool / Managed block are only returned to active Slabs
This commit is contained in:
parent
8260e5d93f
commit
63e39a257e
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +77,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
||||||
return MemoryPoolBlock2.Create(
|
return MemoryPoolBlock2.Create(
|
||||||
new ArraySegment<byte>(new byte[minimumSize]),
|
new ArraySegment<byte>(new byte[minimumSize]),
|
||||||
dataPtr: IntPtr.Zero,
|
dataPtr: IntPtr.Zero,
|
||||||
pool: null,
|
pool: this,
|
||||||
slab: null);
|
slab: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -137,8 +138,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure
|
||||||
/// <param name="block">The block to return. It must have been acquired by calling Lease on the same memory pool instance.</param>
|
/// <param name="block">The block to return. It must have been acquired by calling Lease on the same memory pool instance.</param>
|
||||||
public void Return(MemoryPoolBlock2 block)
|
public void Return(MemoryPoolBlock2 block)
|
||||||
{
|
{
|
||||||
block.Reset();
|
Debug.Assert(block.Pool == this, "Returned block was leased from this pool");
|
||||||
_blocks.Enqueue(block);
|
|
||||||
|
if (block.Slab != null && block.Slab.IsActive)
|
||||||
|
{
|
||||||
|
block.Reset();
|
||||||
|
_blocks.Enqueue(block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue