mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
* Cancel sync IO on Windows when aborting thread. Using CancelIO/CancelIOEx or CancelSynchronousIo on a thread that is moving into a suspended state can cause these calls to hang (they shouldn’t but have been observed to be the case). Fix does the cancel of sync IO after the aborted thread has been resumed, but before releasing suspend locks making sure thread won't be suspend again until after cancel IO call has completed. * Add tests aborting blocking socket and file IO on Windows.
46 lines
790 B
C#
46 lines
790 B
C#
using System;
|
|
using System.Threading;
|
|
using System.Net;
|
|
using System.Net.Sockets;
|
|
using NUnit.Framework;
|
|
using System.IO;
|
|
|
|
using MonoTests.Helpers;
|
|
|
|
namespace MonoTests.System.Net.Sockets
|
|
{
|
|
[TestFixture]
|
|
public class AbortBlockingSocketCallTest
|
|
{
|
|
|
|
void StartBlockingAcceptCall ()
|
|
{
|
|
TcpListener listener = null;
|
|
try
|
|
{
|
|
listener = NetworkHelpers.CreateAndStartTcpListener (out int port);
|
|
Socket socket = listener.AcceptSocket ();
|
|
socket.Close ();
|
|
}
|
|
finally
|
|
{
|
|
if (listener != null)
|
|
listener.Stop ();
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void AbortBlockingAcceptCall ()
|
|
{
|
|
Thread listenerThread = new Thread (StartBlockingAcceptCall);
|
|
listenerThread.Start ();
|
|
Thread.Sleep (2000);
|
|
|
|
listenerThread.Abort ();
|
|
listenerThread.Join ();
|
|
}
|
|
|
|
}
|
|
}
|
|
|