Fix sporadic failures in MonoTests.System.Net.HttpRequestStreamTest on x64 Windows.
authorlateralusX <lateralusx.github@gmail.com>
Thu, 14 Sep 2017 09:06:38 +0000 (11:06 +0200)
committerlateralusX <lateralusx.github@gmail.com>
Thu, 14 Sep 2017 09:06:38 +0000 (11:06 +0200)
commitd378fc8ede4e5ba95ec1e129ff9e1f1c74e3d187
tree1c0a1616e68d1d99770afbe321ce59bde167a19f
parent3e268fb9de0ceaabb70ab6e011777365fa6a93c4
Fix sporadic failures in MonoTests.System.Net.HttpRequestStreamTest on x64 Windows.

MonoTests.System.Net.HttpRequestStreamTest suite has sporadic failures on Windows x64
with following exception:

System.Net.Sockets.SocketException : An operation was attempted on something that is not a socket.

This happens due to a data type and constant size mismatch. w32socket.h defines
INVALID_SOCKET and SOCKET_ERROR for all platforms. On Windows x64, SOCKET is defined
by winsock2.h as 64-bit type as well as INVALID_SOCKET constant, but above code will
define INVALID_SOCKET as a 32-bit constant value. This will in turn cause code to sporadically
fail to detect invalid sockets as returned by win32 API's. This will in turn cause the socket
exception when code continues to use socket as argument to win32 socket API’s.

Current “invalid” x64 codegen for expression:

if (sock == INVALID_SOCKET)

mov         eax,0FFFFFFFFh
cmp         rsi,rax

and with fixed defines, correct 64-bit cmp instruction:

cmp         rsi,0FFFFFFFFFFFFFFFFh

Fix makes sure we get the defines of INVALID_SOCKET and SOCKET_ERROR from winsock2.h
on Windows platforms to be consistent with define of SOCKET type.
mono/metadata/w32socket.h