aboutsummaryrefslogtreecommitdiff
path: root/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/share/classes/sun/nio/ch/DatagramChannelImpl.java')
-rw-r--r--src/share/classes/sun/nio/ch/DatagramChannelImpl.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
index 53e84d4347..b91093f49e 100644
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -49,9 +49,6 @@ class DatagramChannelImpl
// Our file descriptor
private final FileDescriptor fd;
-
- // fd value needed for dev/poll. This value will remain valid
- // even after the value in the file descriptor object has been set to -1
private final int fdVal;
// The protocol family of the socket
@@ -103,7 +100,6 @@ class DatagramChannelImpl
// -- End of fields protected by stateLock
-
public DatagramChannelImpl(SelectorProvider sp)
throws IOException
{
@@ -138,16 +134,27 @@ class DatagramChannelImpl
throw new UnsupportedOperationException("IPv6 not available");
}
}
- this.family = family;
- this.fd = Net.socket(family, false);
- this.fdVal = IOUtil.fdVal(fd);
- this.state = ST_UNCONNECTED;
+
+ ResourceManager.beforeUdpCreate();
+ try {
+ this.family = family;
+ this.fd = Net.socket(family, false);
+ this.fdVal = IOUtil.fdVal(fd);
+ this.state = ST_UNCONNECTED;
+ } catch (IOException ioe) {
+ ResourceManager.afterUdpClose();
+ throw ioe;
+ }
}
public DatagramChannelImpl(SelectorProvider sp, FileDescriptor fd)
throws IOException
{
super(sp);
+
+ // increment UDP count to match decrement when closing
+ ResourceManager.beforeUdpCreate();
+
this.family = Net.isIPv6Available() ?
StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
this.fd = fd;
@@ -742,10 +749,9 @@ class DatagramChannelImpl
localAddress = Net.localAddress(fd);
// flush any packets already received.
- boolean blocking = false;
synchronized (blockingLock()) {
+ boolean blocking = isBlocking();
try {
- blocking = isBlocking();
// remainder of each packet thrown away
ByteBuffer tmpBuf = ByteBuffer.allocate(1);
if (blocking) {