Fix UvLoopHandle.ReleaseHandle on linux
Libuv.loop_close can clear the GCHandle pointer on linux
This commit is contained in:
parent
5c6a53c491
commit
29098d6383
|
|
@ -28,17 +28,20 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
_uv.stop(this);
|
_uv.stop(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ReleaseHandle()
|
unsafe protected override bool ReleaseHandle()
|
||||||
{
|
{
|
||||||
var memory = this.handle;
|
var memory = this.handle;
|
||||||
if (memory != IntPtr.Zero)
|
if (memory != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
// loop_close clears the gcHandlePtr
|
||||||
|
var gcHandlePtr = *(IntPtr*)memory;
|
||||||
|
|
||||||
_uv.loop_close(this);
|
_uv.loop_close(this);
|
||||||
handle = IntPtr.Zero;
|
handle = IntPtr.Zero;
|
||||||
DestroyMemory(memory);
|
|
||||||
|
DestroyMemory(memory, gcHandlePtr);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
|
||||||
unsafe protected static void DestroyMemory(IntPtr memory)
|
unsafe protected static void DestroyMemory(IntPtr memory)
|
||||||
{
|
{
|
||||||
var gcHandlePtr = *(IntPtr*)memory;
|
var gcHandlePtr = *(IntPtr*)memory;
|
||||||
|
DestroyMemory(memory, gcHandlePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe protected static void DestroyMemory(IntPtr memory, IntPtr gcHandlePtr)
|
||||||
|
{
|
||||||
if (gcHandlePtr != IntPtr.Zero)
|
if (gcHandlePtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
var gcHandle = GCHandle.FromIntPtr(gcHandlePtr);
|
var gcHandle = GCHandle.FromIntPtr(gcHandlePtr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue