Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
92cd12d1
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看板
提交
92cd12d1
编写于
6月 05, 2012
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7173515: (se) Selector.open fails with OOME on Solaris when unlimited file descriptors
Reviewed-by: coffeys, chegar
上级
f9b04d2e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
44 deletion
+79
-44
src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
+79
-44
src/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java
src/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java
+0
-0
未找到文件。
src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java
浏览文件 @
92cd12d1
...
...
@@ -26,6 +26,9 @@
package
sun.nio.ch
;
import
java.io.IOException
;
import
java.util.BitSet
;
import
java.util.Map
;
import
java.util.HashMap
;
/**
...
...
@@ -71,44 +74,32 @@ class DevPollArrayWrapper {
static
final
int
OPEN_MAX
=
fdLimit
();
// Number of pollfd structures to create.
//
DP_POLL ioctl
allows up to OPEN_MAX-1
//
dpwrite/ioctl(DP_POLL)
allows up to OPEN_MAX-1
static
final
int
NUM_POLLFDS
=
Math
.
min
(
OPEN_MAX
-
1
,
8192
);
// Base address of the native pollArray
private
final
long
pollArrayAddress
;
// Array of pollfd structs used for driver updates
private
final
AllocatedNativeObject
updatePollArray
;
// Maximum number of POLL_FD structs to update at once
private
final
int
MAX_UPDATE_SIZE
=
Math
.
min
(
OPEN_MAX
,
512
);
// Initial size of arrays for fd registration changes
private
final
int
INITIAL_PENDING_UPDATE_SIZE
=
64
;
DevPollArrayWrapper
()
{
int
allocationSize
=
NUM_POLLFDS
*
SIZE_POLLFD
;
pollArray
=
new
AllocatedNativeObject
(
allocationSize
,
true
);
pollArrayAddress
=
pollArray
.
address
();
allocationSize
=
MAX_UPDATE_SIZE
*
SIZE_POLLFD
;
updatePollArray
=
new
AllocatedNativeObject
(
allocationSize
,
true
);
wfd
=
init
();
}
// maximum size of updatesLow
private
final
int
MAX_UPDATE_ARRAY_SIZE
=
Math
.
min
(
OPEN_MAX
,
64
*
1024
);
// The pollfd array for results from devpoll driver
private
AllocatedNativeObject
pollArray
;
private
final
AllocatedNativeObject
pollArray
;
// Base address of the native pollArray
private
final
long
pollArrayAddress
;
// The fd of the devpoll driver
int
wfd
;
private
int
wfd
;
// The fd of the interrupt line going out
int
outgoingInterruptFD
;
private
int
outgoingInterruptFD
;
// The fd of the interrupt line coming in
int
incomingInterruptFD
;
private
int
incomingInterruptFD
;
// The index of the interrupt FD
int
interruptedIndex
;
private
int
interruptedIndex
;
// Number of updated pollfd entries
int
updated
;
...
...
@@ -123,9 +114,24 @@ class DevPollArrayWrapper {
private
int
[]
updateDescriptors
=
new
int
[
INITIAL_PENDING_UPDATE_SIZE
];
// events for file descriptors with registration changes pending, indexed
// by file descriptor and stored as bytes for efficiency reasons.
private
byte
[]
updateEvents
=
new
byte
[
OPEN_MAX
];
// by file descriptor and stored as bytes for efficiency reasons. For
// file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
// least then the update is stored in a map.
private
final
byte
[]
eventsLow
=
new
byte
[
MAX_UPDATE_ARRAY_SIZE
];
private
Map
<
Integer
,
Byte
>
eventsHigh
;
// Used by release and updateRegistrations to track whether a file
// descriptor is registered with /dev/poll.
private
final
BitSet
registered
=
new
BitSet
();
DevPollArrayWrapper
()
{
int
allocationSize
=
NUM_POLLFDS
*
SIZE_POLLFD
;
pollArray
=
new
AllocatedNativeObject
(
allocationSize
,
true
);
pollArrayAddress
=
pollArray
.
address
();
wfd
=
init
();
if
(
OPEN_MAX
>
MAX_UPDATE_ARRAY_SIZE
)
eventsHigh
=
new
HashMap
<>();
}
void
initInterrupt
(
int
fd0
,
int
fd1
)
{
outgoingInterruptFD
=
fd1
;
...
...
@@ -153,12 +159,30 @@ class DevPollArrayWrapper {
return
pollArray
.
getInt
(
offset
);
}
private
void
setUpdateEvents
(
int
fd
,
byte
events
)
{
if
(
fd
<
MAX_UPDATE_ARRAY_SIZE
)
{
eventsLow
[
fd
]
=
events
;
}
else
{
eventsHigh
.
put
(
Integer
.
valueOf
(
fd
),
Byte
.
valueOf
(
events
));
}
}
private
byte
getUpdateEvents
(
int
fd
)
{
if
(
fd
<
MAX_UPDATE_ARRAY_SIZE
)
{
return
eventsLow
[
fd
];
}
else
{
Byte
result
=
eventsHigh
.
get
(
Integer
.
valueOf
(
fd
));
// result should never be null
return
result
.
byteValue
();
}
}
void
setInterest
(
int
fd
,
int
mask
)
{
synchronized
(
updateLock
)
{
// record the file descriptor and events, expanding the
// respective arrays first if necessary.
int
oldCapacity
=
updateDescriptors
.
length
;
if
(
updateCount
>
=
oldCapacity
)
{
if
(
updateCount
=
=
oldCapacity
)
{
int
newCapacity
=
oldCapacity
+
INITIAL_PENDING_UPDATE_SIZE
;
int
[]
newDescriptors
=
new
int
[
newCapacity
];
System
.
arraycopy
(
updateDescriptors
,
0
,
newDescriptors
,
0
,
oldCapacity
);
...
...
@@ -169,24 +193,26 @@ class DevPollArrayWrapper {
// events are stored as bytes for efficiency reasons
byte
b
=
(
byte
)
mask
;
assert
(
b
==
mask
)
&&
(
b
!=
CANCELLED
);
updateEvents
[
fd
]
=
b
;
setUpdateEvents
(
fd
,
b
)
;
}
}
void
release
(
int
fd
)
{
synchronized
(
updateLock
)
{
// cancel any pending update for this file descriptor
updateEvents
[
fd
]
=
CANCELLED
;
setUpdateEvents
(
fd
,
CANCELLED
)
;
// remove from /dev/poll
register
(
wfd
,
fd
,
POLLREMOVE
);
if
(
registered
.
get
(
fd
))
{
register
(
wfd
,
fd
,
POLLREMOVE
);
registered
.
clear
(
fd
);
}
}
}
void
closeDevPollFD
()
throws
IOException
{
FileDispatcherImpl
.
closeIntFD
(
wfd
);
pollArray
.
free
();
updatePollArray
.
free
();
}
int
poll
(
long
timeout
)
throws
IOException
{
...
...
@@ -203,36 +229,46 @@ class DevPollArrayWrapper {
}
void
updateRegistrations
()
throws
IOException
{
// Populate pollfd array with updated masks
synchronized
(
updateLock
)
{
// Populate pollfd array with updated masks
int
j
=
0
;
int
index
=
0
;
while
(
j
<
updateCount
)
{
int
fd
=
updateDescriptors
[
j
];
short
events
=
updateEvents
[
fd
];
short
events
=
getUpdateEvents
(
fd
);
boolean
isRegistered
=
registered
.
get
(
fd
);
//
skip update if key has been cancelled
//
events = 0 => POLLREMOVE or do-nothing
if
(
events
!=
CANCELLED
)
{
// remove from /dev/poll when the interest ops changes to 0
if
(
events
==
0
)
events
=
POLLREMOVE
;
if
(
events
==
0
)
{
if
(
isRegistered
)
{
events
=
POLLREMOVE
;
registered
.
clear
(
fd
);
}
else
{
events
=
CANCELLED
;
}
}
else
{
if
(!
isRegistered
)
{
registered
.
set
(
fd
);
}
}
}
// populate pollfd array with updated event
putPollFD
(
updatePollArray
,
index
,
fd
,
events
);
// populate pollfd array with updated event
if
(
events
!=
CANCELLED
)
{
putPollFD
(
pollArray
,
index
,
fd
,
events
);
index
++;
if
(
index
>=
MAX_UPDATE_SIZE
)
{
registerMultiple
(
wfd
,
updateP
ollArray
.
address
(),
index
);
if
(
index
>=
NUM_POLLFDS
)
{
registerMultiple
(
wfd
,
p
ollArray
.
address
(),
index
);
index
=
0
;
}
}
j
++;
}
// write any remaining updates
if
(
index
>
0
)
registerMultiple
(
wfd
,
updateP
ollArray
.
address
(),
index
);
registerMultiple
(
wfd
,
p
ollArray
.
address
(),
index
);
updateCount
=
0
;
}
...
...
@@ -273,5 +309,4 @@ class DevPollArrayWrapper {
int
wfd
);
private
static
native
void
interrupt
(
int
fd
);
private
static
native
int
fdLimit
();
}
src/s
hare
/classes/sun/nio/ch/DevPollSelectorProvider.java
→
src/s
olaris
/classes/sun/nio/ch/DevPollSelectorProvider.java
浏览文件 @
92cd12d1
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录