Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
b92b8a14
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看板
提交
b92b8a14
编写于
2月 01, 2013
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8006395: Race in async socket close on Linux
Reviewed-by: alanb, dsamersoff
上级
934917b1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
11 deletion
+87
-11
src/solaris/native/java/net/linux_close.c
src/solaris/native/java/net/linux_close.c
+10
-11
test/java/net/Socket/asyncClose/Race.java
test/java/net/Socket/asyncClose/Race.java
+77
-0
未找到文件。
src/solaris/native/java/net/linux_close.c
浏览文件 @
b92b8a14
...
...
@@ -191,17 +191,6 @@ static int closefd(int fd1, int fd2) {
pthread_mutex_lock
(
&
(
fdEntry
->
lock
));
{
/*
* Send a wakeup signal to all threads blocked on this
* file descriptor.
*/
threadEntry_t
*
curr
=
fdEntry
->
threads
;
while
(
curr
!=
NULL
)
{
curr
->
intr
=
1
;
pthread_kill
(
curr
->
thr
,
sigWakeup
);
curr
=
curr
->
next
;
}
/*
* And close/dup the file descriptor
* (restart if interrupted by signal)
...
...
@@ -214,6 +203,16 @@ static int closefd(int fd1, int fd2) {
}
}
while
(
rv
==
-
1
&&
errno
==
EINTR
);
/*
* Send a wakeup signal to all threads blocked on this
* file descriptor.
*/
threadEntry_t
*
curr
=
fdEntry
->
threads
;
while
(
curr
!=
NULL
)
{
curr
->
intr
=
1
;
pthread_kill
(
curr
->
thr
,
sigWakeup
);
curr
=
curr
->
next
;
}
}
/*
...
...
test/java/net/Socket/asyncClose/Race.java
0 → 100644
浏览文件 @
b92b8a14
/*
* Copyright (c) 2013, 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 8006395
* @summary Race in async socket close on Linux
*/
import
java.io.InputStream
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.net.SocketException
;
import
java.util.concurrent.Phaser
;
// Racey test, will not always fail, but if it does then we have a problem.
public
class
Race
{
final
static
int
THREADS
=
100
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
try
(
ServerSocket
ss
=
new
ServerSocket
(
0
))
{
final
int
port
=
ss
.
getLocalPort
();
final
Phaser
phaser
=
new
Phaser
(
THREADS
+
1
);
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
final
Socket
s
=
new
Socket
(
"localhost"
,
port
);
s
.
setSoLinger
(
false
,
0
);
try
(
Socket
sa
=
ss
.
accept
())
{
sa
.
setSoLinger
(
false
,
0
);
final
InputStream
is
=
s
.
getInputStream
();
Thread
[]
threads
=
new
Thread
[
THREADS
];
for
(
int
j
=
0
;
j
<
THREADS
;
j
++)
{
threads
[
j
]
=
new
Thread
()
{
public
void
run
()
{
try
{
phaser
.
arriveAndAwaitAdvance
();
while
(
is
.
read
()
!=
-
1
)
Thread
.
sleep
(
50
);
}
catch
(
Exception
x
)
{
if
(!(
x
instanceof
SocketException
&&
x
.
getMessage
().
equals
(
"Socket closed"
)))
x
.
printStackTrace
();
// ok, expect Socket closed
}
}};
}
for
(
int
j
=
0
;
j
<
100
;
j
++)
threads
[
j
].
start
();
phaser
.
arriveAndAwaitAdvance
();
s
.
close
();
for
(
int
j
=
0
;
j
<
100
;
j
++)
threads
[
j
].
join
();
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录