Package: mpc
Version: 0.12.1-1
Severity: important

On an IPv6 enabled host that runs mpd locally mpc will report a connection
error if MPD_HOST is not defined and addrinfo list returned by getaddrinfo()
contains more than 1 item.

Here is the error:
-------------------------------------------------------------------------------------
MPD_HOST and/or MPD_PORT environment variables are not set
error: problems getting a response from "localhost" on port 6600 : Connection 
refused
-------------------------------------------------------------------------------------

An investigation with a packet sniffer shows that mpc connects to the mpd
daemon as many times as the number of items in the addrinfo list, even when
the very first connection attempt has been already successfull. The last
connection attempt happens to be to "::1" on IPv6 address space
which fails because mpd does not listen on IPv6.

Another mpd frontend Glurp works just fine.

Obviously, the connection logic must be such that the first successful
connection is used. The attached patch does simply this.

There is a discussion on a similar topic at

http://www.musicpd.org/mantis/view.php?id=1419

however, the guys there went the wrong way.

Workaroud: define MPD_HOST=127.0.0.1 (NOT MPD_HOST=localhost)

Attachments:
1. packet sniffer log (libpcap format, open with wireshark).
2. the patch.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (90, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages mpc depends on:
ii  libc6                         2.7-13     GNU C Library: Shared libraries

mpc recommends no packages.

Versions of packages mpc suggests:
ii  mpd                           0.13.2-1   Music Player Daemon

-- no debconf information

Attachment: mpd_capture
Description: Binary data

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-17 12:34:34.000000000 +0400
@@ -166,7 +166,8 @@
  			closesocket(connection->sock);
  			connection->sock = -1;
  			continue;
-		}
+		} else
+			break;
 	}
 
 	freeaddrinfo(addrinfo);

Reply via email to