提交 372f90d0 编写于 作者: R robm

8075738: Better multi-JVM sharing

Reviewed-by: michaelm
上级 60d3e8ef
...@@ -1521,6 +1521,7 @@ NET_Bind(int fd, struct sockaddr *him, int len) ...@@ -1521,6 +1521,7 @@ NET_Bind(int fd, struct sockaddr *him, int len)
int exclbind = -1; int exclbind = -1;
#endif #endif
int rv; int rv;
int arg, alen;
#ifdef __linux__ #ifdef __linux__
/* /*
...@@ -1537,7 +1538,7 @@ NET_Bind(int fd, struct sockaddr *him, int len) ...@@ -1537,7 +1538,7 @@ NET_Bind(int fd, struct sockaddr *him, int len)
} }
#endif #endif
#if defined(__solaris__) && defined(AF_INET6) #if defined(__solaris__)
/* /*
* Solaris has separate IPv4 and IPv6 port spaces so we * Solaris has separate IPv4 and IPv6 port spaces so we
* use an exclusive bind when SO_REUSEADDR is not used to * use an exclusive bind when SO_REUSEADDR is not used to
...@@ -1547,35 +1548,31 @@ NET_Bind(int fd, struct sockaddr *him, int len) ...@@ -1547,35 +1548,31 @@ NET_Bind(int fd, struct sockaddr *him, int len)
* results in a late bind that fails because the * results in a late bind that fails because the
* corresponding IPv4 port is in use. * corresponding IPv4 port is in use.
*/ */
if (ipv6_available()) { alen = sizeof(arg);
int arg, len; if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(char *)&arg, &alen) == 0) {
len = sizeof(arg); if (useExclBind || arg == 0) {
if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, /*
(char *)&arg, &len) == 0) { * SO_REUSEADDR is disabled or sun.net.useExclusiveBind
if (useExclBind || arg == 0) { * property is true so enable TCP_EXCLBIND or
/* * UDP_EXCLBIND
* SO_REUSEADDR is disabled or sun.net.useExclusiveBind */
* property is true so enable TCP_EXCLBIND or alen = sizeof(arg);
* UDP_EXCLBIND if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg,
*/ &alen) == 0) {
len = sizeof(arg); if (arg == SOCK_STREAM) {
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&arg, level = IPPROTO_TCP;
&len) == 0) { exclbind = TCP_EXCLBIND;
if (arg == SOCK_STREAM) { } else {
level = IPPROTO_TCP; level = IPPROTO_UDP;
exclbind = TCP_EXCLBIND; exclbind = UDP_EXCLBIND;
} else {
level = IPPROTO_UDP;
exclbind = UDP_EXCLBIND;
}
} }
}
arg = 1; arg = 1;
setsockopt(fd, level, exclbind, (char *)&arg, setsockopt(fd, level, exclbind, (char *)&arg,
sizeof(arg)); sizeof(arg));
} }
}
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册