Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b71754ff
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看板
提交
b71754ff
编写于
2月 16, 2015
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8067846: (sctp) InternalError when receiving SendFailedNotification
Reviewed-by: chegar
上级
e060baef
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
190 addition
and
6 deletion
+190
-6
src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c
src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c
+1
-6
test/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java
test/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java
+189
-0
未找到文件。
src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c
浏览文件 @
b71754ff
/*
* Copyright (c) 2009, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 201
5
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -464,11 +464,6 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
union
sctp_notification
*
snp
;
jboolean
allocated
=
JNI_FALSE
;
if
(
rv
>
SCTP_NOTIFICATION_SIZE
)
{
JNU_ThrowInternalError
(
env
,
"should not reach here"
);
return
-
1
;
}
if
(
!
(
msg
->
msg_flags
&
MSG_EOR
)
&&
length
<
SCTP_NOTIFICATION_SIZE
)
{
char
*
newBuf
;
int
rvSAVE
=
rv
;
...
...
test/com/sun/nio/sctp/SctpMultiChannel/SendFailed.java
0 → 100644
浏览文件 @
b71754ff
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 8067846
* @summary Test for send failed notification
*/
import
com.sun.nio.sctp.*
;
import
java.io.IOException
;
import
java.net.InetSocketAddress
;
import
java.net.SocketAddress
;
import
java.nio.ByteBuffer
;
import
static
java
.
lang
.
System
.
out
;
import
static
java
.
nio
.
ByteBuffer
.*;
public
class
SendFailed
{
static
final
SocketAddress
remoteAddress
=
new
InetSocketAddress
(
"127.0.0.1"
,
3000
);
static
final
int
[]
bufferSizes
=
{
20
,
49
,
50
,
51
,
100
,
101
,
1024
,
1025
,
4095
,
4096
,
4097
,
8191
,
8192
,
8193
};
void
test
(
String
[]
args
)
throws
IOException
{
SocketAddress
address
=
null
;
if
(!
Util
.
isSCTPSupported
())
{
out
.
println
(
"SCTP protocol is not supported"
);
out
.
println
(
"Test cannot be run"
);
return
;
}
System
.
out
.
println
(
"remote address: "
+
remoteAddress
);
System
.
out
.
println
(
"Note, remote address should not be up"
);
/* combinations with various buffer sizes, and offsets */
for
(
int
send
=
0
;
send
<
bufferSizes
.
length
;
send
++)
{
for
(
int
recv
=
0
;
recv
<
bufferSizes
.
length
;
recv
++)
{
for
(
boolean
direct
:
new
boolean
[]
{
true
,
false
})
runWithManyOffsets
(
bufferSizes
[
send
],
bufferSizes
[
recv
],
direct
);
}
}
}
void
runWithManyOffsets
(
int
sendBufferSize
,
int
recvBufferSize
,
boolean
direct
)
throws
IOException
{
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
0
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
1
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
3
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
7
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
9
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
13
);
doTest
(
sendBufferSize
,
recvBufferSize
,
direct
,
15
);
}
void
doTest
(
int
sendBufferSize
,
int
recvBufferSize
,
boolean
direct
,
int
offset
)
throws
IOException
{
debug
(
"%n--- Testing with send size:[%d], recv size:[%d], offset:[%d] "
+
", direct [%s]. "
,
sendBufferSize
,
recvBufferSize
,
offset
,
direct
);
try
(
SctpMultiChannel
channel
=
SctpMultiChannel
.
open
())
{
MessageInfo
messageInfo
=
MessageInfo
.
createOutgoing
(
remoteAddress
,
0
);
ByteBuffer
sendBuffer
=
filledBuffer
(
sendBufferSize
,
direct
);
debug
(
"%nAttempting to send to %s. "
,
remoteAddress
);
int
sent
=
channel
.
send
(
sendBuffer
,
messageInfo
);
sendBuffer
.
flip
();
SendFailedNotificationHandler
handler
=
new
SendFailedNotificationHandler
();
ByteBuffer
recvBuffer
=
direct
?
allocateDirect
(
recvBufferSize
)
:
allocate
((
recvBufferSize
));
channel
.
receive
(
recvBuffer
,
null
,
handler
);
// verify sent buffer received by send failed notification
ByteBuffer
buffer
=
handler
.
getSendFailedByteBuffer
();
check
(
buffer
.
remaining
()
==
sent
);
check
(
buffer
.
position
()
==
0
);
check
(
buffer
.
limit
()
==
sent
);
assertSameContent
(
sendBuffer
,
handler
.
getSendFailedByteBuffer
());
}
}
class
SendFailedNotificationHandler
extends
AbstractNotificationHandler
<
Object
>
{
/** Reference to the buffer captured in send failed notification */
private
ByteBuffer
sentBuffer
;
@Override
public
HandlerResult
handleNotification
(
Notification
notification
,
Object
attachment
)
{
fail
(
"Unknown notification type"
);
return
HandlerResult
.
CONTINUE
;
}
@Override
public
HandlerResult
handleNotification
(
AssociationChangeNotification
notification
,
Object
attachment
)
{
AssociationChangeNotification
.
AssocChangeEvent
event
=
notification
.
event
();
debug
(
"%nAssociationChangeNotification"
);
debug
(
"%n Association: %s. "
,
notification
.
association
());
debug
(
"%n Event: %s. "
,
event
);
return
HandlerResult
.
CONTINUE
;
}
@Override
public
HandlerResult
handleNotification
(
SendFailedNotification
notification
,
Object
attachment
)
{
debug
(
"%nSendFailedNotification: %s. "
,
notification
);
sentBuffer
=
notification
.
buffer
();
return
HandlerResult
.
RETURN
;
}
public
ByteBuffer
getSendFailedByteBuffer
()
{
return
sentBuffer
;
}
@Override
public
HandlerResult
handleNotification
(
PeerAddressChangeNotification
pacn
,
Object
attachment
)
{
debug
(
"%nPeerAddressChangeNotification: %s"
,
pacn
);
return
HandlerResult
.
CONTINUE
;
}
@Override
public
HandlerResult
handleNotification
(
ShutdownNotification
notification
,
Object
attachment
)
{
debug
(
"%nShutdownNotification"
);
debug
(
"%n Association: %s. "
,
notification
.
association
());
return
HandlerResult
.
CONTINUE
;
}
}
static
ByteBuffer
filledBuffer
(
int
size
,
boolean
direct
)
{
ByteBuffer
buffer
=
direct
?
allocateDirect
(
size
)
:
allocate
((
size
));
for
(
int
i
=
0
;
i
<
size
;
i
++)
buffer
.
put
((
byte
)
i
);
buffer
.
flip
();
return
buffer
;
}
static
void
assertSameContent
(
ByteBuffer
bb1
,
ByteBuffer
bb2
)
{
if
(!
bb1
.
equals
(
bb2
))
throw
new
RuntimeException
(
"Buffers are not equal; bb1: "
+
bb1
+
", bb2: "
+
bb2
);
}
//--------------------- Infrastructure ---------------------------
boolean
debug
=
true
;
volatile
int
passed
=
0
,
failed
=
0
;
void
pass
()
{
passed
++;}
void
fail
()
{
failed
++;
Thread
.
dumpStack
();}
void
fail
(
String
msg
)
{
System
.
err
.
println
(
msg
);
fail
();}
void
unexpected
(
Throwable
t
)
{
failed
++;
t
.
printStackTrace
();}
void
check
(
boolean
cond
)
{
if
(
cond
)
pass
();
else
fail
();}
void
check
(
boolean
cond
,
String
failMessage
)
{
if
(
cond
)
pass
();
else
fail
(
failMessage
);}
void
debug
(
String
message
,
Object
...
args
)
{
if
(
debug
)
{
out
.
printf
(
message
,
args
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
Class
<?>
k
=
new
Object
(){}.
getClass
().
getEnclosingClass
();
try
{
k
.
getMethod
(
"instanceMain"
,
String
[].
class
)
.
invoke
(
k
.
newInstance
(),
(
Object
)
args
);}
catch
(
Throwable
e
)
{
throw
e
.
getCause
();}}
public
void
instanceMain
(
String
[]
args
)
throws
Throwable
{
try
{
test
(
args
);}
catch
(
Throwable
t
)
{
unexpected
(
t
);}
out
.
printf
(
"%nPassed = %d, failed = %d%n%n"
,
passed
,
failed
);
if
(
failed
>
0
)
throw
new
AssertionError
(
"Some tests failed"
);}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录