Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
da4da995
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看板
提交
da4da995
编写于
10月 22, 2010
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6994079: PlainSocketImpl should close the socket if it fails
Reviewed-by: alanb
上级
95647ee1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
33 deletion
+36
-33
src/share/classes/java/net/AbstractPlainSocketImpl.java
src/share/classes/java/net/AbstractPlainSocketImpl.java
+36
-33
未找到文件。
src/share/classes/java/net/AbstractPlainSocketImpl.java
浏览文件 @
da4da995
...
...
@@ -28,9 +28,7 @@ package java.net;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.InterruptedIOException
;
import
java.io.FileDescriptor
;
import
java.io.ByteArrayOutputStream
;
import
sun.net.ConnectionResetException
;
import
sun.net.NetHooks
;
...
...
@@ -58,7 +56,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
protected
int
fdUseCount
=
0
;
/* lock when increment/decrementing fdUseCount */
protected
Object
fdLock
=
new
Object
();
protected
final
Object
fdLock
=
new
Object
();
/* indicates a close is pending on the file descriptor */
protected
boolean
closePending
=
false
;
...
...
@@ -68,7 +66,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
private
int
CONNECTION_RESET_PENDING
=
1
;
private
int
CONNECTION_RESET
=
2
;
private
int
resetState
;
private
Object
resetLock
=
new
Object
();
private
final
Object
resetLock
=
new
Object
();
/**
* Load net library into runtime.
...
...
@@ -100,25 +98,24 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
protected
void
connect
(
String
host
,
int
port
)
throws
UnknownHostException
,
IOException
{
IOException
pending
=
null
;
boolean
connected
=
false
;
try
{
InetAddress
address
=
InetAddress
.
getByName
(
host
);
this
.
port
=
port
;
this
.
address
=
address
;
try
{
connectToAddress
(
address
,
port
,
timeout
);
return
;
}
catch
(
IOException
e
)
{
pending
=
e
;
connectToAddress
(
address
,
port
,
timeout
);
connected
=
true
;
}
finally
{
if
(!
connected
)
{
try
{
close
();
}
catch
(
IOException
ioe
)
{
/* Do nothing. If connect threw an exception then
it will be passed up the call stack */
}
}
}
catch
(
UnknownHostException
e
)
{
pending
=
e
;
}
// everything failed
close
();
throw
pending
;
}
/**
...
...
@@ -151,22 +148,29 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
* SocketAddress subclass not supported by this socket
* @since 1.4
*/
protected
void
connect
(
SocketAddress
address
,
int
timeout
)
throws
IOException
{
if
(
address
==
null
||
!(
address
instanceof
InetSocketAddress
))
throw
new
IllegalArgumentException
(
"unsupported address type"
);
InetSocketAddress
addr
=
(
InetSocketAddress
)
address
;
if
(
addr
.
isUnresolved
())
throw
new
UnknownHostException
(
addr
.
getHostName
());
this
.
port
=
addr
.
getPort
();
this
.
address
=
addr
.
getAddress
();
protected
void
connect
(
SocketAddress
address
,
int
timeout
)
throws
IOException
{
boolean
connected
=
false
;
try
{
if
(
address
==
null
||
!(
address
instanceof
InetSocketAddress
))
throw
new
IllegalArgumentException
(
"unsupported address type"
);
InetSocketAddress
addr
=
(
InetSocketAddress
)
address
;
if
(
addr
.
isUnresolved
())
throw
new
UnknownHostException
(
addr
.
getHostName
());
this
.
port
=
addr
.
getPort
();
this
.
address
=
addr
.
getAddress
();
connectToAddress
(
this
.
address
,
port
,
timeout
);
return
;
}
catch
(
IOException
e
)
{
// everything failed
close
();
throw
e
;
connected
=
true
;
}
finally
{
if
(!
connected
)
{
try
{
close
();
}
catch
(
IOException
ioe
)
{
/* Do nothing. If connect threw an exception then
it will be passed up the call stack */
}
}
}
}
...
...
@@ -311,7 +315,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
}
}
try
{
FileDescriptor
fd
=
acquireFD
();
acquireFD
();
try
{
socketConnect
(
address
,
port
,
timeout
);
/* socket may have been closed during poll/select */
...
...
@@ -370,7 +374,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
* @param s the connection
*/
protected
void
accept
(
SocketImpl
s
)
throws
IOException
{
FileDescriptor
fd
=
acquireFD
();
acquireFD
();
try
{
socketAccept
(
s
);
}
finally
{
...
...
@@ -562,7 +566,6 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
close
();
}
/*
* "Acquires" and returns the FileDescriptor for this impl
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录