diff options
author | Max Kellermann <max@musicpd.org> | 2017-10-24 20:09:11 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-10-24 20:09:11 +0200 |
commit | b177bffa6a5f1b69639b6cd759dcb16fdd76e5e2 (patch) | |
tree | 762a56d4be9ad9169d2fac7ee3dd672930565d6a /src/system | |
parent | b4b468eb277f14d75ad5bf49df052e7d873156d9 (diff) |
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 2119e4fd3ef, which made the socket
non-blocking right from the start. This fix postpones the
ioctlsocket(FIONBIO) call until after the connect().
Closes #134
Diffstat (limited to 'src/system')
-rw-r--r-- | src/system/EventPipe.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/system/EventPipe.cxx b/src/system/EventPipe.cxx index 177e55347..e56534e2a 100644 --- a/src/system/EventPipe.cxx +++ b/src/system/EventPipe.cxx @@ -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"); |