Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 285576 - media-sound/mpd-0.16: port not opened when bind_to_address is set
Summary: media-sound/mpd-0.16: port not opened when bind_to_address is set
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Christoph Mende (RETIRED)
URL: http://musicpd.org/mantis/view.php?id...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-19 14:17 UTC by Krzysztof Magusiak
Modified: 2011-03-20 21:02 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for /etc/init.d/mpd (mpd.patch,344 bytes, patch)
2009-09-19 14:20 UTC, Krzysztof Magusiak
Details | Diff
My mpd.conf (without comments) (mpd.conf,613 bytes, text/plain)
2010-05-28 19:53 UTC, Krzysztof Magusiak
Details
/etc/hosts (hosts,78 bytes, text/plain)
2011-03-08 14:15 UTC, Krzysztof Magusiak
Details
getaddrinfo.c (getaddrinfo.c,1.31 KB, text/plain)
2011-03-20 21:02 UTC, SpanKY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Magusiak 2009-09-19 14:17:05 UTC
If rc_parallel="YES" and bind_to_address is set to localhost, mpd fails to listen on the port 6600 when booting.
Once the system is started, when you run '/etc/init.d/mpd restart' mpd works correctly.

Reproducible: Sometimes

Steps to Reproduce:
1. Set rc_parallel="YES" in /etc/rc.conf
2. Add mpd to default rc
3. Add: bind_to_address "localhost" to /etc/mpd.conf
4. Reboot

Actual Results:  
mpd starts but you cannot connect to it.
Comment 1 Krzysztof Magusiak 2009-09-19 14:20:21 UTC
Created attachment 204608 [details, diff]
Patch for /etc/init.d/mpd

Adding net as a dependancy solves the problem.
Comment 2 Samuli Suominen (RETIRED) gentoo-dev 2009-09-19 14:22:39 UTC
But it doesn't really need net...
Comment 3 Krzysztof Magusiak 2009-09-19 14:44:46 UTC
(In reply to comment #2)
> But it doesn't really need net...
> 
I agree.

But there were weird things as when I set 'bind_to_address "127.0.0.1"' I was getting the error "Address familly or hostname not supported" when mpd was starting.
Adding net as dependancy was the first thing I thought of that worked.

By the way, when bind_to_address is not set everything works fine. (don't know if it might help)
Comment 4 Samuli Suominen (RETIRED) gentoo-dev 2009-09-19 17:23:52 UTC
How about moving net.lo from "use" to "need" ? It should be enough, but I didn't test it.
Comment 5 Krzysztof Magusiak 2009-09-19 21:06:33 UTC
No, it didn't fix the problem.
Comment 6 Krzysztof Magusiak 2009-09-25 23:48:19 UTC
This bug appears to occur when the status of net.wlan0 is starting and mpd starts. If net.wlan0 finishes starting before mpd is run, everything works fine.
Comment 7 Christoph Mende (RETIRED) gentoo-dev 2009-11-12 19:18:48 UTC
can you retry this with 0.15.5?
Comment 8 Ladislav Laska 2009-11-19 16:49:34 UTC
Hi,

this bug is present in 0.15.5, or at least it seems to be it. However it does not seem to be affected by rc_parallel (I have it turned off)

Mpd is not started during boot (added in default runlevel), but when i restart it manually later, it works just fine. 

Just a notice: net.lo is started in boot runlevel, mpd is in default, so net.lo should be already started when mpd is starting - and it needs only net.lo (in default configuration), so I'm not sure if dep on net will solve it (as net.lo is statically configured to 127.0.0.1, it does not take a long time).

I have no idea why is this happening. Just tried with soundcard muted, but seemed to make no difference. 

Also, there is nothing obviously wrong in /var/log/mpd/mpd.log (except one error about state file missing, but I have tried removing that and it recreates it correctly).

Maybe something causes mpd to crash after it starts?
Comment 9 Christoph Mende (RETIRED) gentoo-dev 2009-12-15 18:16:01 UTC
Does adding "after net" or "after net.lo" to the init script fix this problem?
Comment 10 Krzysztof Magusiak 2009-12-15 21:39:11 UTC
(In reply to comment #9)
> Does adding "after net" or "after net.lo" to the init script fix this problem?
> 
No, it does not.

For me, mpd starts after net.wlan0, which uses wpa_supplicant and is backgrounded (don't know if it may help). But when I don't start net.wlan0, mpd works.
Comment 11 Christoph Mende (RETIRED) gentoo-dev 2009-12-16 10:51:09 UTC
Well, yes, but that doesn't make any sense to me... all mpd needs is net.lo unless you bind it to some public ip address
Comment 12 Krzysztof Magusiak 2009-12-16 19:35:01 UTC
(In reply to comment #11)
> Well, yes, but that doesn't make any sense to me... all mpd needs is net.lo
> unless you bind it to some public ip address
> 

Yes it is strange...

After running some tests, every time my wireless network connection (wlan0) is starting and before the interface gets an address (using dhcpcd), if I start mpd in a terminal in verbose mode I get:

# mpd --stdout --verbose --no-daemon
config: loading file /etc/mpd.conf
listen: binding to address for 127.0.0.1
listen: Failed to listen on 127.0.0.1 (line 70): Failed to look up host "127.0.0.1": Address family for hostname not supported
Aborted
Comment 13 Nicola 2010-05-05 20:27:03 UTC
Same problem here, and I'm using net.wlan0 with wpa_supplicant.

is adding "need net", like the patch says, working??
Comment 14 Krzysztof Magusiak 2010-05-06 17:41:23 UTC
(In reply to comment #13)
> Same problem here, and I'm using net.wlan0 with wpa_supplicant.
> 
> is adding "need net", like the patch says, working??
> 

It works fine as long as you have a connection that is set during the boot. Otherwise, the script is just waiting.
Comment 15 Christoph Mende (RETIRED) gentoo-dev 2010-05-26 07:57:42 UTC
just to be sure, you guys do have "127.0.0.1 localhost" in /etc/hosts, right?
Comment 16 Krzysztof Magusiak 2010-05-26 11:45:48 UTC
(In reply to comment #15)
> just to be sure, you guys do have "127.0.0.1 localhost" in /etc/hosts, right?
> 

I have it.
Comment 17 Christoph Mende (RETIRED) gentoo-dev 2010-05-28 15:24:33 UTC
can you please show me your mpd.conf?
Comment 18 Krzysztof Magusiak 2010-05-28 19:53:56 UTC
Created attachment 233321 [details]
My mpd.conf (without comments)

Here is my mpd.conf file.
Comment 19 Justin Snelgrove 2010-06-20 21:26:56 UTC
This seems to be related to ipv6. I don't know if it's specifically an mpd bug, or an indication of some larger bug with the handling of ipv6 vs. ipv4 loopback.

What happens, for me, when bind_to_address is "localhost", mpd attaches to ::1 (ipv6 loopback) when no non-lo network interface is up, and 127.0.0.1 when any non-lo network interface is up. It also *cannot* bind to 127.0.0.1 unless a non-lo network interface is up, even if bind_to_address is "127.0.0.1" (causing the error in comment #12). I can correctly ping/ping6 localhost on "localhost", "127.0.0.1", and "::1" no matter the state of non-lo network connections, so I think this is more likely an mpd bug.

A workaround, that seems to let it start properly and always be correctly connected to, no matter the state of other network links, is to use bind_to_address = "any". Mind you, this might be less secure (possibly allowing non-localhost computers to connect to and control mpd), but that should be fixable using some basic iptables rules.

You might also be able to work around it by setting USE="-ipv6" for mpd -- I didn't try this.
Comment 20 Christoph Mende (RETIRED) gentoo-dev 2011-02-20 13:59:00 UTC
Please try this with 0.16 and add your /etc/hosts if it does not work
Comment 21 Christoph Mende (RETIRED) gentoo-dev 2011-03-06 08:48:44 UTC
Please reopen if this still happens with 0.16. I cannot reproduce it.
Comment 22 Krzysztof Magusiak 2011-03-08 14:15:28 UTC
Created attachment 265157 [details]
/etc/hosts
Comment 23 Krzysztof Magusiak 2011-03-08 14:18:12 UTC
(In reply to comment #21)
> Please reopen if this still happens with 0.16. I cannot reproduce it.

Still happening with 0.16.1-r2. I have also added my hosts file.
I also tried to add -ipv6 for mpd, but it changed nothing.
Comment 24 Christoph Mende (RETIRED) gentoo-dev 2011-03-14 19:45:06 UTC
Could you please retry with the first line of your hosts changed to "127.0.0.1 chris-glaptop localhost", i.e. hostnames switched?
Also, did anyone report this upstream already?
Comment 25 Krzysztof Magusiak 2011-03-15 11:47:04 UTC
(In reply to comment #24)
> Could you please retry with the first line of your hosts changed to "127.0.0.1
> chris-glaptop localhost", i.e. hostnames switched?
> Also, did anyone report this upstream already?

Changing the order of hostnames changed nothing.
I don't thing that has been reported upstream.
Comment 26 Christoph Mende (RETIRED) gentoo-dev 2011-03-16 21:11:21 UTC
16/220142 <@cirrus> I'm looking at your bug report. can't reproduce.
16/220202 < angelos> me neither, but those in the gentoo bug seem to be able to reproduce it
16/220217 <@cirrus> mpd asks the libc resolver to convert "127.0.0.1" into a sockaddr. the resolver fails.
16/220218 < angelos> I was hoping you had an idea
16/220222 <@cirrus> I say it's a libc bug.

toolchain: Any idea?
Comment 27 SpanKY gentoo-dev 2011-03-19 06:40:40 UTC
works fine for me.  run it through strace and post the log as an attachment:
strace -s 4096 -o log -v mpd --stdout --verbose --no-daemon
Comment 28 Krzysztof Magusiak 2011-03-19 17:09:36 UTC
Must have been fixed in 0.16, because I reinstalled it completely and it starts normally.
Comment 29 SpanKY gentoo-dev 2011-03-20 21:02:29 UTC
Created attachment 266639 [details]
getaddrinfo.c