提交 84c2130a 编写于 作者: C chegar

7098719: -Dsun.net.maxDatagramSockets and Socket constructor does not work...

7098719: -Dsun.net.maxDatagramSockets and Socket constructor does not work correctly with System.gc()
Reviewed-by: michaelm
上级 1f5e9537
...@@ -86,10 +86,11 @@ abstract class AbstractPlainSocketImpl extends SocketImpl ...@@ -86,10 +86,11 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
* is a stream socket (true) or an unconnected UDP socket (false). * is a stream socket (true) or an unconnected UDP socket (false).
*/ */
protected synchronized void create(boolean stream) throws IOException { protected synchronized void create(boolean stream) throws IOException {
fd = new FileDescriptor();
this.stream = stream; this.stream = stream;
if (!stream) { if (!stream) {
ResourceManager.beforeUdpCreate(); ResourceManager.beforeUdpCreate();
// only create the fd after we know we will be able to create the socket
fd = new FileDescriptor();
try { try {
socketCreate(false); socketCreate(false);
} catch (IOException ioe) { } catch (IOException ioe) {
...@@ -98,6 +99,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl ...@@ -98,6 +99,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
throw ioe; throw ioe;
} }
} else { } else {
fd = new FileDescriptor();
socketCreate(true); socketCreate(true);
} }
if (socket != null) if (socket != null)
......
...@@ -70,7 +70,7 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl ...@@ -70,7 +70,7 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
fd1 = new FileDescriptor(); fd1 = new FileDescriptor();
try { try {
super.create(); super.create();
} catch (IOException e) { } catch (SocketException e) {
fd1 = null; fd1 = null;
throw e; throw e;
} }
......
...@@ -81,7 +81,12 @@ class TwoStacksPlainSocketImpl extends AbstractPlainSocketImpl ...@@ -81,7 +81,12 @@ class TwoStacksPlainSocketImpl extends AbstractPlainSocketImpl
*/ */
protected synchronized void create(boolean stream) throws IOException { protected synchronized void create(boolean stream) throws IOException {
fd1 = new FileDescriptor(); fd1 = new FileDescriptor();
super.create(stream); try {
super.create();
} catch (IOException e) {
fd1 = null;
throw e;
}
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册