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 2119e4fd3e
, which made the socket
non-blocking right from the start. This fix postpones the
ioctlsocket(FIONBIO) call until after the connect().
Closes #134
This commit is contained in:
parent
b4b468eb27
commit
b177bffa6a
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user