mirror of
https://github.com/modernuo/ModernUO
synced 2026-08-11 22:23:06 -04:00
- [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.
37 lines
853 B
C#
37 lines
853 B
C#
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();
|
|
}
|
|
}
|