8293842: IPv6-only systems throws UnsupportedOperationException for several socket/TCP options

Co-authored-by: Martin Buchholz <martin@openjdk.org>
Reviewed-by: djelinski, dfuchs
This commit is contained in:
Man Cao 2022-09-15 22:06:18 +00:00
parent bb9aa4eae6
commit 9a40b76ac5
5 changed files with 25 additions and 9 deletions

View file

@ -187,12 +187,16 @@ jint IPv6_supported()
}
#endif /* DONT_ENABLE_IPV6 */
jint reuseport_supported()
jint reuseport_supported(int ipv6_available)
{
/* Do a simple dummy call, and try to figure out from that */
int one = 1;
int rv, s;
s = socket(PF_INET, SOCK_STREAM, 0);
if (ipv6_available) {
s = socket(PF_INET6, SOCK_STREAM, 0);
} else {
s = socket(PF_INET, SOCK_STREAM, 0);
}
if (s < 0) {
return JNI_FALSE;
}