Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IOCP count config var test #106664

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/libraries/System.Threading.ThreadPool/tests/ThreadPoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,22 +1394,26 @@ static async Task RunAsyncIOTest()
var done = new AutoResetEvent(false);

// Receiver
bool stop = false;
var receiveBuffer = new byte[1];
using var listener = new TcpListener(IPAddress.Loopback, 0);
var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
var t = ThreadTestHelpers.CreateGuardedThread(
out Action checkForThreadErrors,
out Action waitForThread,
async () =>
{
while (true)
using (listener)
{
// Accept a connection, receive a byte
using var socket = await listener.AcceptSocketAsync();
int bytesRead =
await socket.ReceiveAsync(new ArraySegment<byte>(receiveBuffer), SocketFlags.None);
Assert.Equal(1, bytesRead);
done.Set(); // indicate byte received
while (!stop)
{
// Accept a connection, receive a byte
using var socket = await listener.AcceptSocketAsync();
int bytesRead =
await socket.ReceiveAsync(new ArraySegment<byte>(receiveBuffer), SocketFlags.None);
Assert.Equal(1, bytesRead);
done.Set(); // indicate byte received
}
}
});
t.IsBackground = true;
Expand All @@ -1427,6 +1431,9 @@ static async Task RunAsyncIOTest()
Assert.Equal(1, bytesSent);
done.CheckedWait(); // wait for byte to the received
}

stop = true;
waitForThread();
}
}).Dispose();
}, ioCompletionPortCount.ToString()).Dispose();
Expand Down
Loading