changeset 5227:2f67b42e027b

7118373: (se) Potential leak file descriptor when deregistrating at around the same time as an async close Reviewed-by: alanb
author robm
date Mon, 23 Apr 2012 21:59:02 +0100
parents 3c42a5e0bc46
children a7b0a75b5bae
files src/share/classes/sun/nio/ch/DatagramChannelImpl.java src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java src/share/classes/sun/nio/ch/SocketChannelImpl.java src/solaris/classes/sun/nio/ch/SinkChannelImpl.java src/solaris/classes/sun/nio/ch/SourceChannelImpl.java
diffstat 5 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Fri Apr 20 10:58:27 2012 -0700
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Apr 23 21:59:02 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, 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
@@ -970,7 +970,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             ResourceManager.afterUdpClose();
 
             // if member of mulitcast group then invalidate all keys
--- a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Fri Apr 20 10:58:27 2012 -0700
+++ b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Mon Apr 23 21:59:02 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, 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
@@ -261,7 +261,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Fri Apr 20 10:58:27 2012 -0700
+++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Mon Apr 23 21:59:02 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, 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
@@ -816,7 +816,8 @@
             // channel from using the old fd, which might be recycled in the
             // meantime and allocated to an entirely different channel.
             //
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
 
             // Signal native threads, if needed.  If a target thread is not
             // currently blocked in an I/O operation then no harm is done since
--- a/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Fri Apr 20 10:58:27 2012 -0700
+++ b/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Mon Apr 23 21:59:02 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, 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
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Fri Apr 20 10:58:27 2012 -0700
+++ b/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Mon Apr 23 21:59:02 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, 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
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);