Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
efcd30d7
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
efcd30d7
编写于
3月 15, 2011
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7026376: (dc) DatagramChannel created without specifying protocol family fails to join IPv4 group
Reviewed-by: chegar
上级
d9840162
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
144 addition
and
70 deletion
+144
-70
make/java/nio/mapfile-linux
make/java/nio/mapfile-linux
+2
-0
make/java/nio/mapfile-solaris
make/java/nio/mapfile-solaris
+2
-0
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+14
-9
src/share/classes/sun/nio/ch/Net.java
src/share/classes/sun/nio/ch/Net.java
+20
-1
src/solaris/native/sun/nio/ch/Net.c
src/solaris/native/sun/nio/ch/Net.c
+16
-0
src/windows/native/sun/nio/ch/Net.c
src/windows/native/sun/nio/ch/Net.c
+12
-0
test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
...o/channels/DatagramChannel/MulticastSendReceiveTests.java
+78
-60
未找到文件。
make/java/nio/mapfile-linux
浏览文件 @
efcd30d7
...
...
@@ -95,6 +95,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_NativeThread_current;
Java_sun_nio_ch_NativeThread_init;
Java_sun_nio_ch_NativeThread_signal;
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0;
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0;
Java_sun_nio_ch_Net_socket0;
Java_sun_nio_ch_Net_bind0;
Java_sun_nio_ch_Net_connect0;
...
...
make/java/nio/mapfile-solaris
浏览文件 @
efcd30d7
...
...
@@ -82,6 +82,8 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_NativeThread_current;
Java_sun_nio_ch_NativeThread_init;
Java_sun_nio_ch_NativeThread_signal;
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0;
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0;
Java_sun_nio_ch_Net_socket0;
Java_sun_nio_ch_Net_bind0;
Java_sun_nio_ch_Net_connect0;
...
...
src/share/classes/sun/nio/ch/DatagramChannelImpl.java
浏览文件 @
efcd30d7
...
...
@@ -755,11 +755,14 @@ class DatagramChannelImpl
throw
new
IllegalArgumentException
(
"Group not a multicast address"
);
// check multicast address is compatible with this socket
if
(!(
group
instanceof
Inet4Address
))
{
if
(
family
==
StandardProtocolFamily
.
INET
)
throw
new
IllegalArgumentException
(
"Group is not IPv4 address"
);
if
(!(
group
instanceof
Inet6Address
))
throw
new
IllegalArgumentException
(
"Address type not supported"
);
if
(
group
instanceof
Inet4Address
)
{
if
(
family
==
StandardProtocolFamily
.
INET6
&&
!
Net
.
canIPv6SocketJoinIPv4Group
())
throw
new
IllegalArgumentException
(
"Group is not IPv4 multicast address"
);
}
else
if
(
group
instanceof
Inet6Address
)
{
if
(
family
!=
StandardProtocolFamily
.
INET6
)
throw
new
IllegalArgumentException
(
"Group is not IPv6 multicast address"
);
}
else
{
throw
new
IllegalArgumentException
(
"Address type not supported"
);
}
// check source address
...
...
@@ -791,7 +794,9 @@ class DatagramChannelImpl
}
MembershipKeyImpl
key
;
if
(
family
==
StandardProtocolFamily
.
INET6
)
{
if
((
family
==
StandardProtocolFamily
.
INET6
)
&&
((
group
instanceof
Inet6Address
)
||
Net
.
canJoin6WithIPv4Group
()))
{
int
index
=
interf
.
getIndex
();
if
(
index
==
-
1
)
throw
new
IOException
(
"Network interface cannot be identified"
);
...
...
@@ -861,7 +866,7 @@ class DatagramChannelImpl
return
;
try
{
if
(
family
==
StandardProtocolFamily
.
INET
6
)
{
if
(
key
instanceof
MembershipKeyImpl
.
Type
6
)
{
MembershipKeyImpl
.
Type6
key6
=
(
MembershipKeyImpl
.
Type6
)
key
;
Net
.
drop6
(
fd
,
key6
.
groupAddress
(),
key6
.
index
(),
key6
.
source
());
...
...
@@ -901,7 +906,7 @@ class DatagramChannelImpl
throw
new
IllegalArgumentException
(
"Source address is different type to group"
);
int
n
;
if
(
family
==
StandardProtocolFamily
.
INET
6
)
{
if
(
key
instanceof
MembershipKeyImpl
.
Type
6
)
{
MembershipKeyImpl
.
Type6
key6
=
(
MembershipKeyImpl
.
Type6
)
key
;
n
=
Net
.
block6
(
fd
,
key6
.
groupAddress
(),
key6
.
index
(),
...
...
@@ -931,7 +936,7 @@ class DatagramChannelImpl
throw
new
IllegalStateException
(
"key is no longer valid"
);
try
{
if
(
family
==
StandardProtocolFamily
.
INET
6
)
{
if
(
key
instanceof
MembershipKeyImpl
.
Type
6
)
{
MembershipKeyImpl
.
Type6
key6
=
(
MembershipKeyImpl
.
Type6
)
key
;
Net
.
unblock6
(
fd
,
key6
.
groupAddress
(),
key6
.
index
(),
...
...
src/share/classes/sun/nio/ch/Net.java
浏览文件 @
efcd30d7
...
...
@@ -60,6 +60,21 @@ class Net { // package-private
return
isIPv6Available
;
}
/**
* Tells whether IPv6 sockets can join IPv4 multicast groups
*/
static
boolean
canIPv6SocketJoinIPv4Group
()
{
return
canIPv6SocketJoinIPv4Group0
();
}
/**
* Tells whether {@link #join6} can be used to join an IPv4
* multicast group (IPv4 group as IPv4-mapped IPv6 address)
*/
static
boolean
canJoin6WithIPv4Group
()
{
return
canJoin6WithIPv4Group0
();
}
static
InetSocketAddress
checkAddress
(
SocketAddress
sa
)
{
if
(
sa
==
null
)
throw
new
NullPointerException
();
...
...
@@ -291,7 +306,11 @@ class Net { // package-private
// -- Socket operations --
static
native
boolean
isIPv6Available0
();
private
static
native
boolean
isIPv6Available0
();
private
static
native
boolean
canIPv6SocketJoinIPv4Group0
();
private
static
native
boolean
canJoin6WithIPv4Group0
();
static
FileDescriptor
socket
(
boolean
stream
)
{
return
socket
(
UNSPEC
,
stream
);
...
...
src/solaris/native/sun/nio/ch/Net.c
浏览文件 @
efcd30d7
...
...
@@ -154,6 +154,22 @@ Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl)
return
(
ipv6_available
())
?
JNI_TRUE
:
JNI_FALSE
;
}
JNIEXPORT
jboolean
JNICALL
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0
(
JNIEnv
*
env
,
jclass
cl
)
{
return
JNI_TRUE
;
}
JNIEXPORT
jboolean
JNICALL
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0
(
JNIEnv
*
env
,
jclass
cl
)
{
#ifdef __solaris__
return
JNI_TRUE
;
#else
return
JNI_FALSE
;
#endif
}
JNIEXPORT
int
JNICALL
Java_sun_nio_ch_Net_socket0
(
JNIEnv
*
env
,
jclass
cl
,
jboolean
preferIPv6
,
jboolean
stream
,
jboolean
reuse
)
...
...
src/windows/native/sun/nio/ch/Net.c
浏览文件 @
efcd30d7
...
...
@@ -100,6 +100,18 @@ Java_sun_nio_ch_Net_isIPv6Available0(JNIEnv* env, jclass cl)
return
JNI_FALSE
;
}
JNIEXPORT
jboolean
JNICALL
Java_sun_nio_ch_Net_canIPv6SocketJoinIPv4Group0
(
JNIEnv
*
env
,
jclass
cl
)
{
return
JNI_FALSE
;
}
JNIEXPORT
jboolean
JNICALL
Java_sun_nio_ch_Net_canJoin6WithIPv4Group0
(
JNIEnv
*
env
,
jclass
cl
)
{
return
JNI_FALSE
;
}
JNIEXPORT
jint
JNICALL
Java_sun_nio_ch_Net_socket0
(
JNIEnv
*
env
,
jclass
cl
,
jboolean
preferIPv6
,
jboolean
stream
,
jboolean
reuse
)
...
...
test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
浏览文件 @
efcd30d7
...
...
@@ -22,7 +22,7 @@
*/
/* @test
* @bug 4527345
* @bug 4527345
7026376
* @summary Unit test for DatagramChannel's multicast support
* @build MulticastSendReceiveTests NetworkConfiguration
* @run main MulticastSendReceiveTests
...
...
@@ -31,12 +31,19 @@
import
java.nio.ByteBuffer
;
import
java.nio.channels.*
;
import
java.net.*
;
import
static
java
.
net
.
StandardProtocolFamily
.*;
import
java.util.*
;
import
java.io.IOException
;
public
class
MulticastSendReceiveTests
{
static
Random
rand
=
new
Random
();
static
final
Random
rand
=
new
Random
();
static
final
ProtocolFamily
UNSPEC
=
new
ProtocolFamily
()
{
public
String
name
()
{
return
"UNSPEC"
;
}
};
/**
* Send datagram from given local address to given multicast
...
...
@@ -130,75 +137,84 @@ public class MulticastSendReceiveTests {
/**
* Exercise multicast send/receive on given group/interface
*/
static
void
test
(
NetworkInterface
nif
,
InetAddress
group
,
InetAddress
source
)
static
void
test
(
ProtocolFamily
family
,
NetworkInterface
nif
,
InetAddress
group
,
InetAddress
source
)
throws
IOException
{
ProtocolFamily
family
=
(
group
instanceof
Inet6Address
)
?
StandardProtocolFamily
.
INET6
:
StandardProtocolFamily
.
INET
;
System
.
out
.
format
(
"create channel to %s socket\n"
,
family
.
name
());
DatagramChannel
dc
=
DatagramChannel
.
open
(
family
)
.
setOption
(
StandardSocketOption
.
SO_REUSEADDR
,
true
)
.
bind
(
new
InetSocketAddress
(
0
));
// join group
System
.
out
.
format
(
"join %s @ %s\n"
,
group
.
getHostAddress
(),
nif
.
getName
());
MembershipKey
key
=
dc
.
join
(
group
,
nif
);
// send message to group
int
port
=
((
InetSocketAddress
)
dc
.
getLocalAddress
()).
getPort
();
int
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
// receive message and check id matches
receiveDatagram
(
dc
,
source
,
id
);
System
.
out
.
format
(
"\nTest DatagramChannel to %s socket\n"
,
family
.
name
());
try
(
DatagramChannel
dc
=
(
family
==
UNSPEC
)
?
DatagramChannel
.
open
()
:
DatagramChannel
.
open
(
family
))
{
dc
.
setOption
(
StandardSocketOption
.
SO_REUSEADDR
,
true
)
.
bind
(
new
InetSocketAddress
(
0
));
// join group
System
.
out
.
format
(
"join %s @ %s\n"
,
group
.
getHostAddress
(),
nif
.
getName
());
MembershipKey
key
;
try
{
key
=
dc
.
join
(
group
,
nif
);
}
catch
(
IllegalArgumentException
iae
)
{
if
(
family
==
UNSPEC
)
{
System
.
out
.
println
(
"Not supported"
);
return
;
}
throw
iae
;
}
// exclude-mode filtering
// send message to group
int
port
=
((
InetSocketAddress
)
dc
.
getLocalAddress
()).
getPort
();
int
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
try
{
System
.
out
.
format
(
"block %s\n"
,
source
.
getHostAddress
()
);
// receive message and check id matches
receiveDatagram
(
dc
,
source
,
id
);
// may throw UOE
key
.
block
(
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
null
,
id
);
// exclude-mode filtering
// unblock source, send message, message should be received
System
.
out
.
format
(
"unblock %s\n"
,
source
.
getHostAddress
());
key
.
unblock
(
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
source
,
id
);
}
catch
(
UnsupportedOperationException
x
)
{
System
.
out
.
println
(
"Exclude-mode filtering not supported!"
);
}
try
{
System
.
out
.
format
(
"block %s\n"
,
source
.
getHostAddress
());
key
.
drop
();
// may throw UOE
key
.
block
(
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
null
,
id
);
// include-mode filtering
// unblock source, send message, message should be received
System
.
out
.
format
(
"unblock %s\n"
,
source
.
getHostAddress
());
key
.
unblock
(
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
source
,
id
);
}
catch
(
UnsupportedOperationException
x
)
{
System
.
out
.
println
(
"Exclude-mode filtering not supported!"
);
}
InetAddress
bogus
=
(
group
instanceof
Inet6Address
)
?
InetAddress
.
getByName
(
"fe80::1234"
)
:
InetAddress
.
getByName
(
"1.2.3.4"
);
System
.
out
.
format
(
"join %s @ %s only-source %s\n"
,
group
.
getHostAddress
(),
nif
.
getName
(),
bogus
.
getHostAddress
());
try
{
// may throw UOE
key
=
dc
.
join
(
group
,
nif
,
bogus
);
key
.
drop
();
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
null
,
id
);
// include-mode filtering
InetAddress
bogus
=
(
group
instanceof
Inet6Address
)
?
InetAddress
.
getByName
(
"fe80::1234"
)
:
InetAddress
.
getByName
(
"1.2.3.4"
);
System
.
out
.
format
(
"join %s @ %s only-source %s\n"
,
group
.
getHostAddress
(),
nif
.
getName
(),
source
.
getHostAddress
());
key
=
dc
.
join
(
group
,
nif
,
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
source
,
id
);
}
catch
(
UnsupportedOperationException
x
)
{
System
.
out
.
println
(
"Include-mode filtering not supported!"
);
nif
.
getName
(),
bogus
.
getHostAddress
());
try
{
// may throw UOE
key
=
dc
.
join
(
group
,
nif
,
bogus
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
null
,
id
);
System
.
out
.
format
(
"join %s @ %s only-source %s\n"
,
group
.
getHostAddress
(),
nif
.
getName
(),
source
.
getHostAddress
());
key
=
dc
.
join
(
group
,
nif
,
source
);
id
=
sendDatagram
(
source
,
nif
,
group
,
port
);
receiveDatagram
(
dc
,
source
,
id
);
}
catch
(
UnsupportedOperationException
x
)
{
System
.
out
.
println
(
"Include-mode filtering not supported!"
);
}
}
// done
dc
.
close
();
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
...
...
@@ -210,12 +226,14 @@ public class MulticastSendReceiveTests {
for
(
NetworkInterface
nif:
config
.
ip4Interfaces
())
{
InetAddress
source
=
config
.
ip4Addresses
(
nif
).
iterator
().
next
();
test
(
nif
,
ip4Group
,
source
);
test
(
INET
,
nif
,
ip4Group
,
source
);
test
(
UNSPEC
,
nif
,
ip4Group
,
source
);
}
for
(
NetworkInterface
nif:
config
.
ip6Interfaces
())
{
InetAddress
source
=
config
.
ip6Addresses
(
nif
).
iterator
().
next
();
test
(
nif
,
ip6Group
,
source
);
test
(
INET6
,
nif
,
ip6Group
,
source
);
test
(
UNSPEC
,
nif
,
ip6Group
,
source
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录