diff options
author | Niklas Therning <niklas@therning.org> | 2016-10-10 17:04:49 +0300 |
---|---|---|
committer | Niklas Therning <niklas@therning.org> | 2016-10-10 18:06:43 +0300 |
commit | 9e4a4ff90ec3b7c536d4348aa21fd7ffec2a43ad (patch) | |
tree | b767dd499db126dc24066bceecf89ac2bcd9a9b5 /mcs/class/test-helpers | |
parent | 082057e3d7247ac5c260355d8145960fbaaa8e76 (diff) |
Fix SocketResponder on Windows
There seems to be a race in some tests in the System test suite that use
SocketResponder on Windows. Some tests fail with an exception that the socket
has been closed before they get a chance to see the response sent by the
SocketResponder. The same happens occasionally when using SocketResponder on
.NET. This patch changes the order of the Socket.Shutdown() calls and adds a
Socket.Receive() before Shutdown() is called to give the sender a chance to
actually send any data before the responder shuts down and closes its side of
the connection.
Diffstat (limited to 'mcs/class/test-helpers')
-rw-r--r-- | mcs/class/test-helpers/SocketResponder.cs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mcs/class/test-helpers/SocketResponder.cs b/mcs/class/test-helpers/SocketResponder.cs index 118d89410e2..74e77b0edf0 100644 --- a/mcs/class/test-helpers/SocketResponder.cs +++ b/mcs/class/test-helpers/SocketResponder.cs @@ -91,8 +91,11 @@ namespace MonoTests.Helpers listenSocket = tcpListener.AcceptSocket (); listenSocket.Send (requestHandler (listenSocket)); try { - listenSocket.Shutdown (SocketShutdown.Receive); + // On Windows a Receive() is needed here before Shutdown() to consume the data some tests send. + listenSocket.ReceiveTimeout = 10 * 1000; + listenSocket.Receive (new byte [0]); listenSocket.Shutdown (SocketShutdown.Send); + listenSocket.Shutdown (SocketShutdown.Receive); } catch { } } catch (SocketException ex) { |