Bug#534504: mediatomb: Daemon starts up too early in the boot process; interface not found
Guillem Jover
guillem at debian.org
Sun Oct 28 01:20:05 UTC 2012
Hi!
On Wed, 2009-06-24 at 23:39:37 +0100, Iain Lane wrote:
> Package: mediatomb
> Version: 0.12.0~svn2018-3ubuntu2
> Severity: important
>
> I've installed mediatomb on my PC but it doesn't launch at boot because
> the interface I've specified in the config file with <interface> doesn't
> exist at the point when the program is ran. The following is present in
> the log file:
>
> 2009-06-24 09:18:51 ERROR: Could not determine interface address:
> Cannot assign requested address
> 2009-06-24 09:18:51 ERROR: Could not find interface: eth3
>
> It works if I restart via the init script after the machine is booted.
The real problem here is that it seems mediatomb unneedingly forces
itself to know the IP of an (outbound) interface at startup and refuses
to work otherwise. Here's a quick (and possibly bogus) analysis of the
code involved:
,---
src/tools.cc (interfaceToIP):
Returns nil and logs an error if it cannot retrieve the IP of the
interface (which I guess is more or less fine, although the output
is annoying).
src/server.cc (Server::upnp_init):
Calls interfaceToIP(iface) if there's no explicit IP specified to the
daemon, and aborts if one cannot be retrieved, otherwise calls
UpnpInit() with the IP, port, etc. Then calls UpnpGetServerIpAddress()
again to retrieve the found address if the IP was not valid (which
cannot be because we've bailed out before). It also tries to start
sending UPnP advertisements.
tombupnp/upnp/src/api/upnpapi.c (UpnpInit):
If HostIP is !NULL it uses that as LOCAL_HOST, otherweise it tries
again to retrieve a local host IP and uses that instead as LOCAL_HOST
(all this by crawling through the physical interfaces).
`---
The correct and proper fix seems to me, would be to:
1) If either no explicit interface or IP has been specified on the
command-line, use getaddrinfo with node == NULL and
hints.ai_flags == AI_PASSIVE, so that we get the INADDR_ANY.
2) Bind to that address for listening.
3) Move the IP retrieval and interface sieve for when sending
outbound advertisement messages, and handle the case of no
interfaces being UP or only loopback as non-errors.
I'm not sure how much work that would imply though, but a media server
like minidlna is doing something like that (not to mention the myriad
of other server software around), and works just fine w/o an initially
setup (outbound) interface.
(BTW, while digging I noticed there's an embedded fork of libupnp,
which from a quick look does not seem to handle this gracefully
either...)
regards,
guillem
More information about the pkg-multimedia-maintainers
mailing list