Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7610a76d
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看板
提交
7610a76d
编写于
7月 22, 2008
作者:
T
tbell
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
36174eaf
4ba7bc76
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
221 addition
and
15 deletion
+221
-15
src/share/classes/java/nio/channels/SelectionKey.java
src/share/classes/java/nio/channels/SelectionKey.java
+1
-1
src/share/classes/sun/nio/ch/SelectorImpl.java
src/share/classes/sun/nio/ch/SelectorImpl.java
+14
-12
test/java/nio/channels/FileChannel/ExpandingMap.java
test/java/nio/channels/FileChannel/ExpandingMap.java
+9
-2
test/java/nio/channels/Selector/Wakeup.java
test/java/nio/channels/Selector/Wakeup.java
+197
-0
未找到文件。
src/share/classes/java/nio/channels/SelectionKey.java
浏览文件 @
7610a76d
...
@@ -191,7 +191,7 @@ public abstract class SelectionKey {
...
@@ -191,7 +191,7 @@ public abstract class SelectionKey {
* @throws IllegalArgumentException
* @throws IllegalArgumentException
* If a bit in the set does not correspond to an operation that
* If a bit in the set does not correspond to an operation that
* is supported by this key's channel, that is, if
* is supported by this key's channel, that is, if
* <tt>
set & ~(
channel().validOps()) != 0</tt>
* <tt>
(ops & ~
channel().validOps()) != 0</tt>
*
*
* @throws CancelledKeyException
* @throws CancelledKeyException
* If this key has been cancelled
* If this key has been cancelled
...
...
src/share/classes/sun/nio/ch/SelectorImpl.java
浏览文件 @
7610a76d
...
@@ -142,18 +142,20 @@ abstract class SelectorImpl
...
@@ -142,18 +142,20 @@ abstract class SelectorImpl
// Precondition: Synchronized on this, keys, and selectedKeys
// Precondition: Synchronized on this, keys, and selectedKeys
Set
cks
=
cancelledKeys
();
Set
cks
=
cancelledKeys
();
synchronized
(
cks
)
{
synchronized
(
cks
)
{
Iterator
i
=
cks
.
iterator
();
if
(!
cks
.
isEmpty
())
{
while
(
i
.
hasNext
())
{
Iterator
i
=
cks
.
iterator
();
SelectionKeyImpl
ski
=
(
SelectionKeyImpl
)
i
.
next
();
while
(
i
.
hasNext
())
{
try
{
SelectionKeyImpl
ski
=
(
SelectionKeyImpl
)
i
.
next
();
implDereg
(
ski
);
try
{
}
catch
(
SocketException
se
)
{
implDereg
(
ski
);
IOException
ioe
=
new
IOException
(
}
catch
(
SocketException
se
)
{
"Error deregistering key"
);
IOException
ioe
=
new
IOException
(
ioe
.
initCause
(
se
);
"Error deregistering key"
);
throw
ioe
;
ioe
.
initCause
(
se
);
}
finally
{
throw
ioe
;
i
.
remove
();
}
finally
{
i
.
remove
();
}
}
}
}
}
}
}
...
...
test/java/nio/channels/FileChannel/ExpandingMap.java
浏览文件 @
7610a76d
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
*/
*/
/* @test
/* @test
* @bug 4938372
* @bug 4938372
6541641
* @summary Flushing dirty pages prior to unmap can cause Cleaner thread to
* @summary Flushing dirty pages prior to unmap can cause Cleaner thread to
* abort VM if memory system has pages locked
* abort VM if memory system has pages locked
*/
*/
...
@@ -39,7 +39,7 @@ import java.util.ArrayList;
...
@@ -39,7 +39,7 @@ import java.util.ArrayList;
public
class
ExpandingMap
{
public
class
ExpandingMap
{
public
static
void
main
(
String
[]
args
)
throws
IO
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
int
initialSize
=
20480
*
1024
;
int
initialSize
=
20480
*
1024
;
int
maximumMapSize
=
16
*
1024
*
1024
;
int
maximumMapSize
=
16
*
1024
*
1024
;
...
@@ -103,6 +103,13 @@ public class ExpandingMap {
...
@@ -103,6 +103,13 @@ public class ExpandingMap {
}
}
}
}
fc
.
close
();
// cleanup the ref to mapped buffers so they can be GCed
for
(
int
i
=
0
;
i
<
buffers
.
length
;
i
++)
buffers
[
i
]
=
null
;
System
.
gc
();
// Take a nap to wait for the Cleaner to cleanup those unrefed maps
Thread
.
sleep
(
1000
);
System
.
out
.
println
(
"TEST PASSED"
);
System
.
out
.
println
(
"TEST PASSED"
);
}
}
...
...
test/java/nio/channels/Selector/Wakeup.java
0 → 100644
浏览文件 @
7610a76d
/*
* Copyright 2001-2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6405995
* @summary Unit test for selector wakeup and interruption
* @library ..
*/
import
java.io.*
;
import
java.net.*
;
import
java.nio.*
;
import
java.nio.channels.*
;
import
java.util.Random
;
public
class
Wakeup
{
static
void
sleep
(
int
millis
)
{
try
{
Thread
.
sleep
(
millis
);
}
catch
(
InterruptedException
x
)
{
x
.
printStackTrace
();
}
}
static
class
Sleeper
extends
TestThread
{
volatile
boolean
started
=
false
;
volatile
int
entries
=
0
;
volatile
int
wakeups
=
0
;
volatile
boolean
wantInterrupt
=
false
;
volatile
boolean
gotInterrupt
=
false
;
volatile
Exception
exception
=
null
;
volatile
boolean
closed
=
false
;
Object
gate
=
new
Object
();
Selector
sel
;
Sleeper
(
Selector
sel
)
{
super
(
"Sleeper"
,
System
.
err
);
this
.
sel
=
sel
;
}
public
void
go
()
throws
Exception
{
started
=
true
;
for
(;;)
{
synchronized
(
gate
)
{
}
entries
++;
try
{
sel
.
select
();
}
catch
(
ClosedSelectorException
x
)
{
closed
=
true
;
}
boolean
intr
=
Thread
.
currentThread
().
isInterrupted
();
wakeups
++;
System
.
err
.
println
(
"Wakeup "
+
wakeups
+
(
closed
?
" (closed)"
:
""
)
+
(
intr
?
" (intr)"
:
""
));
if
(
wakeups
>
1000
)
throw
new
Exception
(
"Too many wakeups"
);
if
(
closed
)
return
;
if
(
wantInterrupt
)
{
while
(!
Thread
.
interrupted
())
Thread
.
yield
();
gotInterrupt
=
true
;
wantInterrupt
=
false
;
}
}
}
}
private
static
int
checkedWakeups
=
0
;
private
static
void
check
(
Sleeper
sleeper
,
boolean
intr
)
throws
Exception
{
checkedWakeups
++;
if
(
sleeper
.
wakeups
>
checkedWakeups
)
{
sleeper
.
finish
(
100
);
throw
new
Exception
(
"Sleeper has run ahead"
);
}
int
n
=
0
;
while
(
sleeper
.
wakeups
<
checkedWakeups
)
{
sleep
(
50
);
if
((
n
+=
50
)
>
1000
)
{
sleeper
.
finish
(
100
);
throw
new
Exception
(
"Sleeper appears to be dead ("
+
checkedWakeups
+
")"
);
}
}
if
(
sleeper
.
wakeups
>
checkedWakeups
)
{
sleeper
.
finish
(
100
);
throw
new
Exception
(
"Too many wakeups: Expected "
+
checkedWakeups
+
", got "
+
sleeper
.
wakeups
);
}
if
(
intr
)
{
n
=
0
;
// Interrupts can sometimes be delayed, so wait
while
(!
sleeper
.
gotInterrupt
)
{
sleep
(
50
);
if
((
n
+=
50
)
>
1000
)
{
sleeper
.
finish
(
100
);
throw
new
Exception
(
"Interrupt never delivered"
);
}
}
sleeper
.
gotInterrupt
=
false
;
}
System
.
err
.
println
(
"Check "
+
checkedWakeups
+
(
intr
?
" (intr "
+
n
+
")"
:
""
));
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Selector
sel
=
Selector
.
open
();
// Wakeup before select
sel
.
wakeup
();
Sleeper
sleeper
=
new
Sleeper
(
sel
);
sleeper
.
start
();
while
(!
sleeper
.
started
)
sleep
(
50
);
check
(
sleeper
,
false
);
// 1
for
(
int
i
=
2
;
i
<
5
;
i
++)
{
// Wakeup during select
sel
.
wakeup
();
check
(
sleeper
,
false
);
// 2 .. 4
}
// Double wakeup
synchronized
(
sleeper
.
gate
)
{
sel
.
wakeup
();
check
(
sleeper
,
false
);
// 5
sel
.
wakeup
();
sel
.
wakeup
();
}
check
(
sleeper
,
false
);
// 6
// Interrupt
synchronized
(
sleeper
.
gate
)
{
sleeper
.
wantInterrupt
=
true
;
sleeper
.
interrupt
();
check
(
sleeper
,
true
);
// 7
}
// Interrupt before select
while
(
sleeper
.
entries
<
8
)
Thread
.
yield
();
synchronized
(
sleeper
.
gate
)
{
sel
.
wakeup
();
check
(
sleeper
,
false
);
// 8
sleeper
.
wantInterrupt
=
true
;
sleeper
.
interrupt
();
sleep
(
50
);
}
check
(
sleeper
,
true
);
// 9
// Close during select
while
(
sleeper
.
entries
<
10
)
Thread
.
yield
();
synchronized
(
sleeper
.
gate
)
{
sel
.
close
();
check
(
sleeper
,
false
);
// 10
}
if
(
sleeper
.
finish
(
200
)
==
0
)
throw
new
Exception
(
"Test failed"
);
if
(!
sleeper
.
closed
)
throw
new
Exception
(
"Selector not closed"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录