summaryrefslogtreecommitdiff
path: root/src/system
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-10-24 20:09:11 +0200
committerMax Kellermann <max@musicpd.org>2017-10-24 20:09:11 +0200
commitb177bffa6a5f1b69639b6cd759dcb16fdd76e5e2 (patch)
tree762a56d4be9ad9169d2fac7ee3dd672930565d6a /src/system
parentb4b468eb277f14d75ad5bf49df052e7d873156d9 (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.cxx4
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");