mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 15:45:56 -05:00
IPv4 binding failure is fatal in all cases
IPv4 and IPv6 are bound separately; IPv6 may fail if unsupported, IPv4 must always succeed.
This commit is contained in:
parent
ed38ce7dd1
commit
588b328b45
19
src/httpd.c
19
src/httpd.c
@ -1201,7 +1201,6 @@ int
|
||||
httpd_init(void)
|
||||
{
|
||||
unsigned short port;
|
||||
int bindv6;
|
||||
int ret;
|
||||
|
||||
httpd_exit = 0;
|
||||
@ -1278,20 +1277,20 @@ httpd_init(void)
|
||||
|
||||
port = cfg_getint(cfg_getsec(cfg, "library"), "port");
|
||||
|
||||
/* evhttp doesn't support IPv6 yet, so this is expected to fail */
|
||||
bindv6 = evhttp_bind_socket(evhttpd, "::", port);
|
||||
if (bindv6 < 0)
|
||||
DPRINTF(E_INFO, L_HTTPD, "Could not bind IN6ADDR_ANY:%d (that's OK)\n", port);
|
||||
/* We are binding v6 and v4 separately, and we allow v6 to fail
|
||||
* as IPv6 might not be supported on the system.
|
||||
* We still warn about the failure, in case there's another issue.
|
||||
*/
|
||||
ret = evhttp_bind_socket(evhttpd, "::", port);
|
||||
if (ret < 0)
|
||||
DPRINTF(E_WARN, L_HTTPD, "Could not bind IN6ADDR_ANY:%d (that's OK)\n", port);
|
||||
|
||||
ret = evhttp_bind_socket(evhttpd, "0.0.0.0", port);
|
||||
if (ret < 0)
|
||||
{
|
||||
if (bindv6 < 0)
|
||||
{
|
||||
DPRINTF(E_FATAL, L_HTTPD, "Could not bind INADDR_ANY:%d\n", port);
|
||||
DPRINTF(E_FATAL, L_HTTPD, "Could not bind INADDR_ANY:%d\n", port);
|
||||
|
||||
goto bind_fail;
|
||||
}
|
||||
goto bind_fail;
|
||||
}
|
||||
|
||||
evhttp_set_gencb(evhttpd, httpd_gen_cb, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user