fix: Fixes issue with wepoll losing GCHandle. (#1039)
- [X] Fixes issue with wepoll losing GCHandle. - [X] `NetState.Disconnect()` is no longer thread safe. - Use `Core.LoopContext.Post()` to post disconnects - [X] Optimizes PollGroup by not processing IntPtr -> GCHandle for discard polls.
This commit is contained in:
parent
d261973cee
commit
aeec7f78fd
3 changed files with 72 additions and 25 deletions
37
Projects/Server.Tests/Tests/Network/PollGroupTests.cs
Normal file
37
Projects/Server.Tests/Tests/Network/PollGroupTests.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Server.Network;
|
||||
using Xunit;
|
||||
|
||||
namespace Server.Tests.Network;
|
||||
|
||||
public class PollGroupTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestPollGroup()
|
||||
{
|
||||
// var group = new KQueuePollGroup();
|
||||
var nss = new NetState[2048];
|
||||
var handles = new IntPtr[2048];
|
||||
for (var i = 0; i < nss.Length; i++)
|
||||
{
|
||||
nss[i] = PacketTestUtilities.CreateTestNetState();
|
||||
handles[i] = (IntPtr)nss[i].Handle;
|
||||
}
|
||||
|
||||
GC.AddMemoryPressure(10000000000);
|
||||
GC.Collect();
|
||||
GC.RemoveMemoryPressure(10000000000);
|
||||
GC.Collect();
|
||||
|
||||
Thread.Sleep(1000);
|
||||
|
||||
for (var i = 0; i < nss.Length; i++)
|
||||
{
|
||||
Assert.Equal(nss[i].Handle, (GCHandle)handles[i]);
|
||||
}
|
||||
|
||||
// group.Dispose();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue