Skip to content

Commit

Permalink
[System.Net] do not use Thread for SocketTest.TestSelect1 (#8364)
Browse files Browse the repository at this point in the history
it makes the test less reliable. Potentially helps with
#8360
  • Loading branch information
lewurm authored and luhenry committed Apr 20, 2018
1 parent 736683e commit 9b47d56
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mcs/class/System/Test/System.Net.Sockets/SocketTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,11 @@ public void TestSelect1 ()
{
Socket srv = CreateServer (NetworkHelpers.FindFreePort ());
ClientSocket clnt = new ClientSocket (srv.LocalEndPoint);
Thread th = new Thread (new ThreadStart (clnt.ConnectSleepClose));
Socket acc = null;
try {
th.Start ();
acc = srv.Accept ();
clnt.Connect ();
clnt.Write ();
acc = srv.Accept ();
ArrayList list = new ArrayList ();
ArrayList empty = new ArrayList ();
list.Add (acc);
Expand All @@ -279,6 +278,7 @@ public void TestSelect1 ()
if (acc != null)
acc.Close ();
srv.Close ();
clnt.Close ();
}
}

Expand All @@ -300,10 +300,13 @@ public ClientSocket (EndPoint ep)
sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}

public void ConnectSleepClose ()
public void Connect ()
{
sock.Connect (ep);
Thread.Sleep (2000);
}

public void Close ()
{
sock.Close ();
}

Expand Down

0 comments on commit 9b47d56

Please sign in to comment.