Fix hostname resolution for mpd_host
authorPhil Sutter <phil@nwl.cc>
Sun, 31 May 2009 01:36:12 +0000 (03:36 +0200)
committerBrenden Matthews <brenden@rty.ca>
Sun, 31 May 2009 01:55:06 +0000 (19:55 -0600)
When getaddrinfo() returns an IPv6 address, connect() fails since mpd
does not support IPv6. Reproduced by adding the name "localhost" to the
"::1" entry in /etc/hosts.

Signed-off-by: Brenden Matthews <brenden@rty.ca>

ChangeLog
src/libmpdclient.c

index d9a3468..de4a21f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2009-05-31
+       * Fix hostname resolution for mpd_host
+
 2009-05-24
        * Added fancy new 'temperature gradients' feature for graphs, via the -t
        switch at the end of graph arguments.
index 6e2b261..3df620a 100644 (file)
@@ -126,9 +126,13 @@ static int mpd_connect(mpd_Connection *connection, const char *host, int port,
        struct addrinfo *res = NULL;
        struct addrinfo *addrinfo = NULL;
 
-       /* Setup hints */
+       /* Setup hints
+        *
+        * XXX: limit address family to PF_INET here.
+        * MPD does not support IPv6 yet, so if GAI returns
+        * an IPv6 address, the later connect() will fail. */
        hints.ai_flags          = AI_ADDRCONFIG;
-       hints.ai_family         = PF_UNSPEC;
+       hints.ai_family         = PF_INET;
        hints.ai_socktype       = SOCK_STREAM;
        hints.ai_protocol       = IPPROTO_TCP;
        hints.ai_addrlen        = 0;