mpd failed to start after `/etc/init.d/mpd restart`. After failed restart, I can start `/etc/init.d/mpd start` without any problems. When I add `sleep 1` in stop() or start() restart works fine. Reproducible: Always Steps to Reproduce: 1./etc/init.d/mpd start 2./etc/init.d/mpd restart Actual Results: localhost ~ # /etc/init.d/mpd restart * Stopping Music Player Daemon... [ ok ] * Starting Music Player Daemon... listen: Failed to listen on localhost (line 69): Address already in use /etc/init.d/mpd: line 20: 20034 Aborted /usr/bin/mpd /etc/mpd.conf [ !! ] * ERROR: mpd failed to start
Reproduced on a Intel Quad Core; + 25 Jul 2009; Samuli Suominen <ssuominen@gentoo.org> files/mpd.rc: + sleep 0.1 when stopping wrt #278969, thanks to Adam Adasko. This fixed it for me; committed in tree without revbump. Please test.
media-sound/mpd-0.15.12: I can still reproduce this sometimes even with sleep 0.1 on a Intel Core2 Duo @2.50GHz. Increasing it to sleep 0.2 probably fixed it, but I don't know if this is really the right solution. stop() { ebegin "Stopping Music Player Daemon" /usr/bin/mpd --kill /etc/mpd.conf sleep 0.2 eend $? } What's more, won't $? now return the value of sleep instead of mpd -kill? I'd rather put this in the start() function instead of stop(): start() { checkconfig || return 1 ebegin "Starting Music Player Daemon" sleep 0.2 /usr/bin/mpd /etc/mpd.conf eend $? } But maybe there's a better solution than sleep.