Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a8f9b5c8
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看板
提交
a8f9b5c8
编写于
4月 16, 2012
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7143744: (se) Stabilize KQueue SelectorProvider and make default on MacOSX
Reviewed-by: michaelm, chegar
上级
6e2cf390
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
79 addition
and
39 deletion
+79
-39
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
+4
-2
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
+5
-3
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
+58
-18
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
+3
-1
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
+3
-1
test/java/nio/channels/Selector/OpRead.java
test/java/nio/channels/Selector/OpRead.java
+4
-1
test/sun/nio/ch/SelProvider.java
test/sun/nio/ch/SelProvider.java
+2
-13
未找到文件。
src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
浏览文件 @
a8f9b5c8
...
...
@@ -4,7 +4,9 @@
*
* 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.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -40,7 +42,7 @@ public class DefaultSelectorProvider {
* Returns the default SelectorProvider.
*/
public
static
SelectorProvider
create
()
{
return
new
sun
.
nio
.
ch
.
Poll
SelectorProvider
();
return
new
sun
.
nio
.
ch
.
KQueue
SelectorProvider
();
}
}
src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java
浏览文件 @
a8f9b5c8
...
...
@@ -4,7 +4,9 @@
*
* 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.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -64,8 +66,8 @@ class KQueueArrayWrapper {
static
short
FD_OFFSET
;
static
short
FILTER_OFFSET
;
// kevent array size
(just under 1K bytes)
static
final
int
NUM_KEVENTS
=
50
;
// kevent array size
static
final
int
NUM_KEVENTS
=
128
;
// Are we in a 64-bit VM?
static
boolean
is64bit
=
false
;
...
...
src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java
浏览文件 @
a8f9b5c8
...
...
@@ -4,7 +4,9 @@
*
* 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.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -49,8 +51,8 @@ class KQueueSelectorImpl
// Count of registered descriptors (including interrupt)
private
int
totalChannels
;
// Map from
file descriptors to selection keys
private
HashMap
<
Integer
,
SelectionKeyImpl
>
fdToKey
;
// Map from
a file descriptor to an entry containing the selection key
private
HashMap
<
Integer
,
MapEntry
>
fdMap
;
// True if this Selector has been closed
private
boolean
closed
=
false
;
...
...
@@ -59,6 +61,20 @@ class KQueueSelectorImpl
private
Object
interruptLock
=
new
Object
();
private
boolean
interruptTriggered
=
false
;
// used by updateSelectedKeys to handle cases where the same file
// descriptor is polled by more than one filter
private
long
updateCount
;
// Used to map file descriptors to a selection key and "update count"
// (see updateSelectedKeys for usage).
private
static
class
MapEntry
{
SelectionKeyImpl
ski
;
long
updateCount
;
MapEntry
(
SelectionKeyImpl
ski
)
{
this
.
ski
=
ski
;
}
}
/**
* Package private constructor called by factory method in
* the abstract superclass Selector.
...
...
@@ -70,7 +86,7 @@ class KQueueSelectorImpl
fd1
=
(
int
)
fds
;
kqueueWrapper
=
new
KQueueArrayWrapper
();
kqueueWrapper
.
initInterrupt
(
fd0
,
fd1
);
fd
ToKey
=
new
HashMap
<>();
fd
Map
=
new
HashMap
<>();
totalChannels
=
1
;
}
...
...
@@ -82,8 +98,6 @@ class KQueueSelectorImpl
if
(
closed
)
throw
new
ClosedSelectorException
();
processDeregisterQueue
();
if
(
timeout
==
0
&&
totalChannels
==
1
)
return
0
;
try
{
begin
();
entries
=
kqueueWrapper
.
poll
(
timeout
);
...
...
@@ -94,10 +108,9 @@ class KQueueSelectorImpl
return
updateSelectedKeys
(
entries
);
}
/**
* Update the keys whose fd's have been selected by
the devpoll
*
driver. Add the ready keys to the ready queue
.
* Update the keys whose fd's have been selected by
kqueue.
*
Add the ready keys to the selected key set
.
* If the interrupt fd has been selected, drain it and clear the interrupt.
*/
private
int
updateSelectedKeys
(
int
entries
)
...
...
@@ -106,24 +119,42 @@ class KQueueSelectorImpl
int
numKeysUpdated
=
0
;
boolean
interrupted
=
false
;
// A file descriptor may be registered with kqueue with more than one
// filter and so there may be more than one event for a fd. The update
// count in the MapEntry tracks when the fd was last updated and this
// ensures that the ready ops are updated rather than replaced by a
// second or subsequent event.
updateCount
++;
for
(
int
i
=
0
;
i
<
entries
;
i
++)
{
int
nextFD
=
kqueueWrapper
.
getDescriptor
(
i
);
if
(
nextFD
==
fd0
)
{
interrupted
=
true
;
}
else
{
SelectionKeyImpl
ski
=
fdToKey
.
get
(
new
Integer
(
nextFD
));
// ski is null in the case of an interrupt
if
(
ski
!=
null
)
{
MapEntry
me
=
fdMap
.
get
(
Integer
.
valueOf
(
nextFD
));
// entry is null in the case of an interrupt
if
(
me
!=
null
)
{
int
rOps
=
kqueueWrapper
.
getReventOps
(
i
);
SelectionKeyImpl
ski
=
me
.
ski
;
if
(
selectedKeys
.
contains
(
ski
))
{
if
(
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
))
{
numKeysUpdated
++;
// first time this file descriptor has been encountered on this
// update?
if
(
me
.
updateCount
!=
updateCount
)
{
if
(
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
))
{
numKeysUpdated
++;
me
.
updateCount
=
updateCount
;
}
}
else
{
// ready ops have already been set on this update
ski
.
channel
.
translateAndUpdateReadyOps
(
rOps
,
ski
);
}
}
else
{
ski
.
channel
.
translateAndSetReadyOps
(
rOps
,
ski
);
if
((
ski
.
readyOps
()
&
ski
.
i
nterestOps
())
!=
0
)
{
if
((
ski
.
nioReadyOps
()
&
ski
.
nioI
nterestOps
())
!=
0
)
{
selectedKeys
.
add
(
ski
);
numKeysUpdated
++;
me
.
updateCount
=
updateCount
;
}
}
}
...
...
@@ -137,7 +168,6 @@ class KQueueSelectorImpl
interruptTriggered
=
false
;
}
}
return
numKeysUpdated
;
}
...
...
@@ -145,6 +175,12 @@ class KQueueSelectorImpl
protected
void
implClose
()
throws
IOException
{
if
(!
closed
)
{
closed
=
true
;
// prevent further wakeup
synchronized
(
interruptLock
)
{
interruptTriggered
=
true
;
}
FileDispatcherImpl
.
closeIntFD
(
fd0
);
FileDispatcherImpl
.
closeIntFD
(
fd1
);
if
(
kqueueWrapper
!=
null
)
{
...
...
@@ -172,8 +208,10 @@ class KQueueSelectorImpl
protected
void
implRegister
(
SelectionKeyImpl
ski
)
{
if
(
closed
)
throw
new
ClosedSelectorException
();
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
fd
ToKey
.
put
(
new
Integer
(
fd
),
ski
);
fd
Map
.
put
(
Integer
.
valueOf
(
fd
),
new
MapEntry
(
ski
)
);
totalChannels
++;
keys
.
add
(
ski
);
}
...
...
@@ -181,7 +219,7 @@ class KQueueSelectorImpl
protected
void
implDereg
(
SelectionKeyImpl
ski
)
throws
IOException
{
int
fd
=
ski
.
channel
.
getFDVal
();
fd
ToKey
.
remove
(
new
Integer
(
fd
));
fd
Map
.
remove
(
Integer
.
valueOf
(
fd
));
kqueueWrapper
.
release
(
fd
);
totalChannels
--;
keys
.
remove
(
ski
);
...
...
@@ -194,6 +232,8 @@ class KQueueSelectorImpl
public
void
putEventOps
(
SelectionKeyImpl
ski
,
int
ops
)
{
if
(
closed
)
throw
new
ClosedSelectorException
();
int
fd
=
IOUtil
.
fdVal
(
ski
.
channel
.
getFD
());
kqueueWrapper
.
setInterest
(
fd
,
ops
);
}
...
...
src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java
浏览文件 @
a8f9b5c8
...
...
@@ -4,7 +4,9 @@
*
* 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.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c
浏览文件 @
a8f9b5c8
...
...
@@ -4,7 +4,9 @@
*
* 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.
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
test/java/nio/channels/Selector/OpRead.java
浏览文件 @
a8f9b5c8
...
...
@@ -58,7 +58,10 @@ public class OpRead {
boolean
done
=
false
;
int
failCount
=
0
;
while
(!
done
)
{
if
(
selector
.
select
()
>
0
)
{
int
nSelected
=
selector
.
select
();
if
(
nSelected
>
0
)
{
if
(
nSelected
>
1
)
throw
new
RuntimeException
(
"More than one channel selected"
);
Set
<
SelectionKey
>
keys
=
selector
.
selectedKeys
();
Iterator
<
SelectionKey
>
iterator
=
keys
.
iterator
();
while
(
iterator
.
hasNext
())
{
...
...
test/sun/nio/ch/SelProvider.java
浏览文件 @
a8f9b5c8
...
...
@@ -38,20 +38,9 @@ public class SelProvider {
if
(
"SunOS"
.
equals
(
osname
))
{
expected
=
"sun.nio.ch.DevPollSelectorProvider"
;
}
else
if
(
"Linux"
.
equals
(
osname
))
{
String
[]
vers
=
osver
.
split
(
"\\."
,
0
);
if
(
vers
.
length
>=
2
)
{
int
major
=
Integer
.
parseInt
(
vers
[
0
]);
int
minor
=
Integer
.
parseInt
(
vers
[
1
]);
if
(
major
>
2
||
(
major
==
2
&&
minor
>=
6
))
{
expected
=
"sun.nio.ch.EPollSelectorProvider"
;
}
else
{
expected
=
"sun.nio.ch.PollSelectorProvider"
;
}
}
else
{
throw
new
RuntimeException
(
"Test does not recognize this operating system"
);
}
expected
=
"sun.nio.ch.EPollSelectorProvider"
;
}
else
if
(
osname
.
startsWith
(
"Mac OS"
))
{
expected
=
"sun.nio.ch.
Poll
SelectorProvider"
;
expected
=
"sun.nio.ch.
KQueue
SelectorProvider"
;
}
else
return
;
if
(!
spName
.
equals
(
expected
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录