aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-24 18:55:12 +0100
committerMax Kellermann <max@duempel.org>2009-02-24 18:55:12 +0100
commitd0a17ffb9d858753f4cb3ce2e9c9ea44c6484f7c (patch)
tree2277cd2427bbab5bf5615d5220acf96384aee87a /src
parentadf044eb098175fb3d15e95946c4ac403c521b54 (diff)
downloadmpd-d0a17ffb9d858753f4cb3ce2e9c9ea44c6484f7c.tar.gz
mpd-d0a17ffb9d858753f4cb3ce2e9c9ea44c6484f7c.tar.xz
mpd-d0a17ffb9d858753f4cb3ce2e9c9ea44c6484f7c.zip
listen: removed is_ipv6_enabled()
Don't explicitly check is_ipv6_enabled(), just try calling listen_add_port_ipv6(), but check its error code.
Diffstat (limited to '')
-rw-r--r--src/listen.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/listen.c b/src/listen.c
index 614518bcc..e8306cd1e 100644
--- a/src/listen.c
+++ b/src/listen.c
@@ -136,19 +136,6 @@ listen_add_address(int pf, const struct sockaddr *addrp, socklen_t addrlen,
return true;
}
-#ifdef HAVE_IPV6
-static bool
-is_ipv6_enabled(void)
-{
- int s;
- s = socket(AF_INET6, SOCK_STREAM, 0);
- if (s == -1)
- return false;
- close(s);
- return true;
-}
-#endif
-
#ifdef HAVE_TCP
/**
@@ -211,24 +198,32 @@ listen_add_port(unsigned int port, GError **error)
#ifdef HAVE_TCP
bool success;
#ifdef HAVE_IPV6
- int ipv6_enabled = is_ipv6_enabled();
-
+ bool success6;
+ GError *error2 = NULL;
#endif
g_debug("binding to any address");
#ifdef HAVE_IPV6
- if (ipv6_enabled) {
- success = listen_add_port_ipv6(port, error);
- if (!success)
+ success6 = listen_add_port_ipv6(port, &error2);
+ if (!success6) {
+ if (error2->domain != listen_quark() ||
+ (error2->code != EAFNOSUPPORT && error2->code != EINVAL &&
+ error2->code != EPROTONOSUPPORT)) {
+ g_propagate_error(error, error2);
return false;
+ }
+
+ /* although MPD was compiled with IPv6 support, this
+ host does not have it - ignore this error */
+ g_error_free(error2);
}
#endif
success = listen_add_port_ipv4(port, error);
if (!success) {
#ifdef HAVE_IPV6
- if (ipv6_enabled)
+ if (success6)
/* non-critical: IPv6 listener is
already set up */
g_clear_error(error);