event/ServerSocket: don't abort if IPv6 is not available
First check if an IPv6 socket can be created.
This commit is contained in:
parent
ecf12a60e8
commit
7bca61f5bb
1
NEWS
1
NEWS
|
@ -4,6 +4,7 @@ ver 0.18.1 (2013/11/??)
|
||||||
* networking:
|
* networking:
|
||||||
- log UNIX domain path names instead of "localhost"
|
- log UNIX domain path names instead of "localhost"
|
||||||
- open listener sockets in the order they were configured
|
- open listener sockets in the order they were configured
|
||||||
|
- don't abort if IPv6 is not available
|
||||||
* filter:
|
* filter:
|
||||||
- autoconvert: fix "volume_normalization" with mp3 files
|
- autoconvert: fix "volume_normalization" with mp3 files
|
||||||
* add missing files to source tarball
|
* add missing files to source tarball
|
||||||
|
|
|
@ -339,6 +339,7 @@ ServerSocket::AddPortIPv4(unsigned port)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ServerSocket::AddPortIPv6(unsigned port)
|
ServerSocket::AddPortIPv6(unsigned port)
|
||||||
{
|
{
|
||||||
|
@ -349,6 +350,22 @@ ServerSocket::AddPortIPv6(unsigned port)
|
||||||
|
|
||||||
AddAddress((const sockaddr &)sin, sizeof(sin));
|
AddAddress((const sockaddr &)sin, sizeof(sin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is IPv6 supported by the kernel?
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
static bool
|
||||||
|
SupportsIPv6()
|
||||||
|
{
|
||||||
|
int fd = socket(AF_INET6, SOCK_STREAM, 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_IPV6 */
|
#endif /* HAVE_IPV6 */
|
||||||
|
|
||||||
#endif /* HAVE_TCP */
|
#endif /* HAVE_TCP */
|
||||||
|
@ -363,7 +380,8 @@ ServerSocket::AddPort(unsigned port, Error &error)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
AddPortIPv6(port);
|
if (SupportsIPv6())
|
||||||
|
AddPortIPv6(port);
|
||||||
#endif
|
#endif
|
||||||
AddPortIPv4(port);
|
AddPortIPv4(port);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue