Commit b177bffa authored by Max Kellermann's avatar Max Kellermann

system/EventPipe: fix WSAEINPROGRESS on Windows

Apparently, connecting a socket to a loopback address can block on Windows, and a non-blocking socket will return WSAEINPROGRESS. This broken PoorSocketPair() in commit 2119e4fd, which made the socket non-blocking right from the start. This fix postpones the ioctlsocket(FIONBIO) call until after the connect(). Closes #134
parent b4b468eb
......@@ -113,12 +113,14 @@ PoorSocketPair(int fd[2])
throw MakeSocketError("Failed to listen on socket");
UniqueSocketDescriptor socket0;
if (!socket0.CreateNonBlock(AF_INET, SOCK_STREAM, IPPROTO_TCP))
if (!socket0.Create(AF_INET, SOCK_STREAM, IPPROTO_TCP))
throw MakeSocketError("Failed to create socket");
if (!socket0.Connect(listen_socket.GetLocalAddress()))
throw MakeSocketError("Failed to connect socket");
socket0.SetNonBlocking();
auto socket1 = listen_socket.AcceptNonBlock();
if (!socket1.IsDefined())
throw MakeSocketError("Failed to accept connection");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment