On Mon, Sep 01, 2008 at 10:35:53AM +0200, Sebastian Harl wrote:
> Hi Stanislav,
> Thanks for reporting this and the helpful links provided.
>
> I was able to reproduce the reported behavior after adding "::1
> localhost" to /etc/hosts. I will check if the patch supplied with
> #495430 will fix this issue as well. If that works out fine, I'll try to
> get a freeze exception so this fix will hopefully make it in Lenny.
Better apply the attached patch, it was exctracted from libmpdclient SVN.
See the related discussion is at the libmpdclient's bugtracker
(the second link I sent in my previous mail).
--
Stanislav
diff -urN mpc-0.12.1-orig/src/libmpdclient.c mpc-0.12.1/src/libmpdclient.c
--- mpc-0.12.1-orig/src/libmpdclient.c 2007-03-21 21:22:41.000000000 +0300
+++ mpc-0.12.1/src/libmpdclient.c 2008-08-18 21:27:52.000000000 +0400
@@ -95,18 +95,21 @@
const struct sockaddr *serv_addr, int addrlen)
{
int iMode = 1; /* 0 = blocking, else non-blocking */
+ if (connect(connection->sock, serv_addr, addrlen) == SOCKET_ERROR)
+ return 1;
ioctlsocket(connection->sock, FIONBIO, (u_long FAR*) &iMode);
- return (connect(connection->sock,serv_addr,addrlen) == SOCKET_ERROR
- && WSAGetLastError() != WSAEWOULDBLOCK);
+ return 0;
}
#else /* !WIN32 (sane operating systems) */
static int do_connect_fail(mpd_Connection *connection,
const struct sockaddr *serv_addr, int addrlen)
{
- int flags = fcntl(connection->sock, F_GETFL, 0);
+ int flags;
+ if (connect(connection->sock, serv_addr, addrlen) < 0)
+ return 1;
+ flags = fcntl(connection->sock, F_GETFL, 0);
fcntl(connection->sock, F_SETFL, flags | O_NONBLOCK);
- return (connect(connection->sock,serv_addr,addrlen)<0 &&
- errno!=EINPROGRESS);
+ return 0;
}
#endif /* !WIN32 */
@@ -162,11 +165,13 @@
/* connect stuff */
if (do_connect_fail(connection,
res->ai_addr, res->ai_addrlen)) {
- /* try the next address family */
+ /* try the next address */
closesocket(connection->sock);
connection->sock = -1;
continue;
}
+
+ break;
}
freeaddrinfo(addrinfo);