Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1848a278
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看板
提交
1848a278
编写于
1月 11, 2017
作者:
V
vtewari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8075484: SocketInputStream.socketRead0 can hang even with soTimeout set
Reviewed-by: chegar, dsamersoff, msheppar, clanger
上级
584b6277
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
96 addition
and
31 deletion
+96
-31
src/aix/native/java/net/aix_close.c
src/aix/native/java/net/aix_close.c
+8
-11
src/solaris/native/java/net/SocketInputStream.c
src/solaris/native/java/net/SocketInputStream.c
+51
-2
src/solaris/native/java/net/bsd_close.c
src/solaris/native/java/net/bsd_close.c
+7
-6
src/solaris/native/java/net/linux_close.c
src/solaris/native/java/net/linux_close.c
+7
-11
src/solaris/native/java/net/net_util_md.c
src/solaris/native/java/net/net_util_md.c
+18
-0
src/solaris/native/java/net/net_util_md.h
src/solaris/native/java/net/net_util_md.h
+5
-1
未找到文件。
src/aix/native/java/net/aix_close.c
浏览文件 @
1848a278
/*
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, SAP SE 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
...
...
@@ -328,6 +329,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
0
)
);
}
int
NET_NonBlockingRead
(
int
s
,
void
*
buf
,
size_t
len
)
{
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
MSG_NONBLOCK
));
}
int
NET_ReadV
(
int
s
,
const
struct
iovec
*
vector
,
int
count
)
{
BLOCKING_IO_RETURN_INT
(
s
,
readv
(
s
,
vector
,
count
)
);
}
...
...
@@ -429,8 +434,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal.
*/
int
NET_Timeout
(
int
s
,
long
timeout
)
{
long
prevtime
=
0
,
newtime
;
int
NET_Timeout
0
(
int
s
,
long
timeout
,
long
currentTime
)
{
long
prevtime
=
currentTime
,
newtime
;
struct
timeval
t
;
fdEntry_t
*
fdEntry
=
getFdEntry
(
s
);
...
...
@@ -442,14 +447,6 @@ int NET_Timeout(int s, long timeout) {
return
-
1
;
}
/*
* Pick up current time as may need to adjust timeout
*/
if
(
timeout
>
0
)
{
gettimeofday
(
&
t
,
NULL
);
prevtime
=
t
.
tv_sec
*
1000
+
t
.
tv_usec
/
1000
;
}
for
(;;)
{
struct
pollfd
pfd
;
int
rv
;
...
...
src/solaris/native/java/net/SocketInputStream.c
浏览文件 @
1848a278
/*
* Copyright (c) 1997, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 201
6
, 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
...
...
@@ -52,6 +52,42 @@ Java_java_net_SocketInputStream_init(JNIEnv *env, jclass cls) {
IO_fd_fdID
=
NET_GetFileDescriptorID
(
env
);
}
#if !defined(__solaris__)
static
int
NET_ReadWithTimeout
(
JNIEnv
*
env
,
int
fd
,
char
*
bufP
,
int
len
,
long
timeout
)
{
int
result
=
0
;
long
prevtime
=
NET_GetCurrentTime
(),
newtime
;
while
(
timeout
>
0
)
{
result
=
NET_TimeoutWithCurrentTime
(
fd
,
timeout
,
prevtime
);
if
(
result
<=
0
)
{
if
(
result
==
0
)
{
JNU_ThrowByName
(
env
,
"java/net/SocketTimeoutException"
,
"Read timed out"
);
}
else
if
(
result
==
-
1
)
{
if
(
errno
==
EBADF
)
{
JNU_ThrowByName
(
env
,
"java/net/SocketException"
,
"Socket closed"
);
}
else
if
(
errno
==
ENOMEM
)
{
JNU_ThrowOutOfMemoryError
(
env
,
"NET_Timeout native heap allocation failed"
);
}
else
{
JNU_ThrowByNameWithMessageAndLastError
(
env
,
"java/net/SocketException"
,
"select/poll failed"
);
}
}
return
-
1
;
}
result
=
NET_NonBlockingRead
(
fd
,
bufP
,
len
);
if
(
result
==
-
1
&&
((
errno
==
EAGAIN
)
||
(
errno
==
EWOULDBLOCK
)))
{
newtime
=
NET_GetCurrentTime
();
timeout
-=
newtime
-
prevtime
;
if
(
timeout
>
0
)
{
prevtime
=
newtime
;
}
}
else
{
break
;
}
}
return
result
;
}
#endif
/*
* Class: java_net_SocketInputStream
* Method: socketRead0
...
...
@@ -99,6 +135,7 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
bufP
=
BUF
;
}
#if defined(__solaris__)
if
(
timeout
)
{
nread
=
NET_Timeout
(
fd
,
timeout
);
if
(
nread
<=
0
)
{
...
...
@@ -126,7 +163,19 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
}
nread
=
NET_Read
(
fd
,
bufP
,
len
);
#else
if
(
timeout
)
{
nread
=
NET_ReadWithTimeout
(
env
,
fd
,
bufP
,
len
,
timeout
);
if
((
*
env
)
->
ExceptionCheck
(
env
))
{
if
(
bufP
!=
BUF
)
{
free
(
bufP
);
}
return
nread
;
}
}
else
{
nread
=
NET_Read
(
fd
,
bufP
,
len
);
}
#endif
if
(
nread
<=
0
)
{
if
(
nread
<
0
)
{
...
...
src/solaris/native/java/net/bsd_close.c
浏览文件 @
1848a278
/*
* Copyright (c) 2001, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
6
, 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
...
...
@@ -292,6 +292,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
0
)
);
}
int
NET_NonBlockingRead
(
int
s
,
void
*
buf
,
size_t
len
)
{
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
MSG_DONTWAIT
));
}
int
NET_ReadV
(
int
s
,
const
struct
iovec
*
vector
,
int
count
)
{
BLOCKING_IO_RETURN_INT
(
s
,
readv
(
s
,
vector
,
count
)
);
}
...
...
@@ -344,8 +348,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal.
*/
int
NET_Timeout
(
int
s
,
long
timeout
)
{
long
prevtime
=
0
,
newtime
;
int
NET_Timeout
0
(
int
s
,
long
timeout
,
long
currentTime
)
{
long
prevtime
=
currentTime
,
newtime
;
struct
timeval
t
,
*
tp
=
&
t
;
fd_set
fds
;
fd_set
*
fdsp
=
NULL
;
...
...
@@ -366,9 +370,6 @@ int NET_Timeout(int s, long timeout) {
*/
if
(
timeout
>
0
)
{
/* Timed */
struct
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
prevtime
=
now
.
tv_sec
*
1000
+
now
.
tv_usec
/
1000
;
t
.
tv_sec
=
timeout
/
1000
;
t
.
tv_usec
=
(
timeout
%
1000
)
*
1000
;
}
else
if
(
timeout
<
0
)
{
...
...
src/solaris/native/java/net/linux_close.c
浏览文件 @
1848a278
/*
* Copyright (c) 2001, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 201
6
, 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
...
...
@@ -273,6 +273,10 @@ int NET_Read(int s, void* buf, size_t len) {
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
0
)
);
}
int
NET_NonBlockingRead
(
int
s
,
void
*
buf
,
size_t
len
)
{
BLOCKING_IO_RETURN_INT
(
s
,
recv
(
s
,
buf
,
len
,
MSG_DONTWAIT
)
);
}
int
NET_ReadV
(
int
s
,
const
struct
iovec
*
vector
,
int
count
)
{
BLOCKING_IO_RETURN_INT
(
s
,
readv
(
s
,
vector
,
count
)
);
}
...
...
@@ -324,8 +328,8 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* Auto restarts with adjusted timeout if interrupted by
* signal other than our wakeup signal.
*/
int
NET_Timeout
(
int
s
,
long
timeout
)
{
long
prevtime
=
0
,
newtime
;
int
NET_Timeout
0
(
int
s
,
long
timeout
,
long
currentTime
)
{
long
prevtime
=
currentTime
,
newtime
;
struct
timeval
t
;
fdEntry_t
*
fdEntry
=
getFdEntry
(
s
);
...
...
@@ -337,14 +341,6 @@ int NET_Timeout(int s, long timeout) {
return
-
1
;
}
/*
* Pick up current time as may need to adjust timeout
*/
if
(
timeout
>
0
)
{
gettimeofday
(
&
t
,
NULL
);
prevtime
=
t
.
tv_sec
*
1000
+
t
.
tv_usec
/
1000
;
}
for
(;;)
{
struct
pollfd
pfd
;
int
rv
;
...
...
src/solaris/native/java/net/net_util_md.c
浏览文件 @
1848a278
...
...
@@ -33,6 +33,7 @@
#include <netdb.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <sys/time.h>
#ifndef _ALLBSD_SOURCE
#include <values.h>
...
...
@@ -1661,3 +1662,20 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
return
timeout
;
}
#if !defined(__solaris__)
long
NET_GetCurrentTime
()
{
struct
timeval
time
;
gettimeofday
(
&
time
,
NULL
);
return
(
time
.
tv_sec
*
1000
+
time
.
tv_usec
/
1000
);
}
int
NET_TimeoutWithCurrentTime
(
int
s
,
long
timeout
,
long
currentTime
)
{
return
NET_Timeout0
(
s
,
timeout
,
currentTime
);
}
int
NET_Timeout
(
int
s
,
long
timeout
)
{
long
currentTime
=
(
timeout
>
0
)
?
NET_GetCurrentTime
()
:
0
;
return
NET_Timeout0
(
s
,
timeout
,
currentTime
);
}
#endif
src/solaris/native/java/net/net_util_md.h
浏览文件 @
1848a278
...
...
@@ -47,9 +47,13 @@
close subroutine does not return until the select call returns.
...
*/
#if
defined(__linux__) || defined(MACOSX) || defined (_AIX
)
#if
!defined(__solaris__
)
extern
int
NET_Timeout
(
int
s
,
long
timeout
);
extern
int
NET_Timeout0
(
int
s
,
long
timeout
,
long
currentTime
);
extern
int
NET_Read
(
int
s
,
void
*
buf
,
size_t
len
);
extern
int
NET_NonBlockingRead
(
int
s
,
void
*
buf
,
size_t
len
);
extern
int
NET_TimeoutWithCurrentTime
(
int
s
,
long
timeout
,
long
currentTime
);
extern
long
NET_GetCurrentTime
();
extern
int
NET_RecvFrom
(
int
s
,
void
*
buf
,
int
len
,
unsigned
int
flags
,
struct
sockaddr
*
from
,
int
*
fromlen
);
extern
int
NET_ReadV
(
int
s
,
const
struct
iovec
*
vector
,
int
count
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录