changeset 1351:3eac78bf6732

Merge
author asaha
date Thu, 28 Apr 2016 09:48:54 -0700
parents 2e13be3dc84c 889731f1c4fc
children d363179c431c
files .hgtags
diffstat 7 files changed, 148 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Apr 11 12:30:18 2016 -0700
+++ b/.hgtags	Thu Apr 28 09:48:54 2016 -0700
@@ -575,6 +575,10 @@
 cd7cec8fd295c0462a813b5f54dc5457c2bade2d jdk8u91-b00
 4ea02753e66e348ee4639e157061bcbdef1d7ff3 jdk8u91-b13
 f8d0cfaa9900ebda679fa9df8319fb753858f283 jdk8u91-b14
+7b719c1dec62535c34030cf3457abe6f478f13a0 jdk8u77-b00
+cafc1648f432eff2c392040af2db4505c3d290b6 jdk8u77-b01
+0f0077ee5e53365562ff77a01aa97d0c7374f447 jdk8u77-b02
+e8dc6eb11c761f20b44d8c4b8acb0846268872f1 jdk8u77-b03
 7deeb4f70404e4f52306f9d0bcfc482fc5f16fb3 jdk8u76-b00
 5786892e7c7d512ef9104a469ff7eafeaac12c38 jdk8u76-b01
 239155e48af89968b62e695a3233d42bed1a3282 jdk8u76-b02
@@ -630,4 +634,13 @@
 8674aec1be6459f33451690fb106eec314964116 jdk8u101-b01
 96a43945cb6a69989294b511ecdfc0493ea09bf1 jdk8u101-b02
 371b0c5477d8613c06fd1206deed27759f18e42e jdk8u101-b03
+52cca1ce8b473ecd751da2350d4b3ef111b5676e jdk8u101-b04
+3edb6296456161d67bf33a73faf18dc57ef548de jdk8u101-b05
+223d0e48a55b92255f5a613743a99e7deacaf455 jdk8u102-b00
+223d0e48a55b92255f5a613743a99e7deacaf455 jdk8u82-b00
+9d09a2f1395561fe71b1a83f53907ddc52e699d6 jdk8u102-b01
+564fbe28cbb0ff2e6f55623807ea816042de00ff jdk8u102-b02
+ab7dbd58a766fb01c6643f3a80c9e96ac1278a06 jdk8u102-b03
+626d8fa7a1bfd9e65b94117a526ba57b25ec3d14 jdk8u102-b04
+3c35b66b5345f615a3ff626111587c452c8c3893 jdk8u102-b05
 52cca1ce8b473ecd751da2350d4b3ef111b5676e jdk8u111-b00
--- a/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/CorbaInboundConnectionCacheImpl.java	Thu Apr 28 09:48:54 2016 -0700
@@ -54,11 +54,17 @@
 {
     protected Collection connectionCache;
 
+    private Acceptor acceptor;
+
     public CorbaInboundConnectionCacheImpl(ORB orb, Acceptor acceptor)
     {
         super(orb, acceptor.getConnectionCacheType(),
               ((CorbaAcceptor)acceptor).getMonitoringName());
         this.connectionCache = new ArrayList();
+        this.acceptor = acceptor;
+        if (orb.transportDebugFlag) {
+            dprint(": " + acceptor );
+        }
     }
 
     ////////////////////////////////////////////////////
@@ -66,11 +72,25 @@
     // pept.transport.InboundConnectionCache
     //
 
+    public void close () {
+
+        super.close();
+        if (orb.transportDebugFlag) {
+            dprint(".close: " + acceptor );
+        }
+        this.acceptor.close();
+
+    }
+
     public Connection get(Acceptor acceptor)
     {
         throw wrapper.methodShouldNotBeCalled();
     }
 
+    public Acceptor getAcceptor () {
+        return acceptor;
+    }
+
     public void put(Acceptor acceptor, Connection connection)
     {
         if (orb.transportDebugFlag) {
--- a/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/CorbaTransportManagerImpl.java	Thu Apr 28 09:48:54 2016 -0700
@@ -188,8 +188,9 @@
             for (Object cc : outboundConnectionCaches.values()) {
                 ((ConnectionCache)cc).close() ;
             }
-            for (Object cc : inboundConnectionCaches.values()) {
-                ((ConnectionCache)cc).close() ;
+            for (Object icc : inboundConnectionCaches.values()) {
+                ((ConnectionCache)icc).close() ;
+                unregisterAcceptor(((InboundConnectionCache)icc).getAcceptor());
             }
             getSelector(0).close();
         } finally {
--- a/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java	Thu Apr 28 09:48:54 2016 -0700
@@ -26,16 +26,20 @@
 package com.sun.corba.se.impl.transport;
 
 import java.io.IOException;
+import java.net.ServerSocket;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.SelectableChannel;
+import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
+import java.nio.channels.ClosedSelectorException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Iterator;
 import java.util.List;
 
+
 import com.sun.corba.se.pept.broker.Broker;
 import com.sun.corba.se.pept.transport.Acceptor;
 import com.sun.corba.se.pept.transport.Connection;
@@ -111,7 +115,16 @@
                 interestOpsList.add(keyAndOp);
             }
             // tell Selector Thread there's an update to a SelectorKey's Ops
-            selector.wakeup();
+            try {
+                if (selector != null) {
+                    // wakeup Selector thread to process close request
+                    selector.wakeup();
+                }
+            } catch (Throwable t) {
+                if (orb.transportDebugFlag) {
+                    dprint(".registerInterestOps: selector.wakeup: ", t);
+                }
+            }
         }
         else {
             wrapper.selectionKeyInvalid(eventHandler.toString());
@@ -186,7 +199,9 @@
             if (selectionKey != null) {
                 selectionKey.cancel();
             }
-            selector.wakeup();
+            if (selector != null) {
+                selector.wakeup();
+            }
             return;
         }
 
@@ -239,6 +254,8 @@
             readerThread.close();
         }
 
+       clearDeferredRegistrations();
+
         // Selector
 
         try {
@@ -248,7 +265,7 @@
             }
         } catch (Throwable t) {
             if (orb.transportDebugFlag) {
-                dprint(".close: selector.close: " + t);
+                dprint(".close: selector.wakeup: ", t);
             }
         }
     }
@@ -273,15 +290,16 @@
                     n = selector.select(timeout);
                 } catch (IOException  e) {
                     if (orb.transportDebugFlag) {
-                        dprint(".run: selector.select: " + e);
+                        dprint(".run: selector.select: ", e);
                     }
+                } catch (ClosedSelectorException csEx) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".run: selector.select: ", csEx);
+                    }
+                    break;
                 }
                 if (closed) {
-                    selector.close();
-                    if (orb.transportDebugFlag) {
-                        dprint(".run: closed - .run return");
-                    }
-                    return;
+                    break;
                 }
                 /*
                   if (timeout == 0 && orb.transportDebugFlag) {
@@ -321,6 +339,18 @@
                 }
             }
         }
+        try {
+            if (selector != null) {
+                if (orb.transportDebugFlag) {
+                    dprint(".run: selector.close ");
+                }
+                selector.close();
+            }
+        } catch (Throwable t) {
+            if (orb.transportDebugFlag) {
+                dprint(".run: selector.close: ", t);
+            }
+        }
     }
 
     /////////////////////////////////////////////////////
@@ -328,6 +358,44 @@
     // Implementation.
     //
 
+    private void clearDeferredRegistrations() {
+        synchronized (deferredRegistrations) {
+            int deferredListSize = deferredRegistrations.size();
+            if (orb.transportDebugFlag) {
+                dprint(".clearDeferredRegistrations:deferred list size == " + deferredListSize);
+            }
+            for (int i = 0; i < deferredListSize; i++) {
+                EventHandler eventHandler =
+                    (EventHandler)deferredRegistrations.get(i);
+                if (orb.transportDebugFlag) {
+                    dprint(".clearDeferredRegistrations: " + eventHandler);
+                }
+                SelectableChannel channel = eventHandler.getChannel();
+                SelectionKey selectionKey = null;
+
+                try {
+                    if (orb.transportDebugFlag) {
+                        dprint(".clearDeferredRegistrations:close channel == "
+                                + channel);
+                        dprint(".clearDeferredRegistrations:close channel class == "
+                                + channel.getClass().getName());
+                    }
+                    channel.close();
+                    selectionKey = eventHandler.getSelectionKey();
+                    if (selectionKey != null) {
+                        selectionKey.cancel();
+                        selectionKey.attach(null);
+                    }
+                } catch (IOException ioEx) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".clearDeferredRegistrations: ", ioEx);
+                    }
+                }
+            }
+            deferredRegistrations.clear();
+        }
+    }
+
     private synchronized boolean isClosed ()
     {
         return closed;
@@ -344,7 +412,7 @@
             selector = Selector.open();
         } catch (IOException e) {
             if (orb.transportDebugFlag) {
-                dprint(".startSelector: Selector.open: IOException: " + e);
+                dprint(".startSelector: Selector.open: IOException: ", e);
             }
             // REVISIT - better handling/reporting
             RuntimeException rte =
@@ -379,7 +447,7 @@
                                          (Object)eventHandler);
                 } catch (ClosedChannelException e) {
                     if (orb.transportDebugFlag) {
-                        dprint(".handleDeferredRegistrations: " + e);
+                        dprint(".handleDeferredRegistrations: ", e);
                     }
                 }
                 eventHandler.setSelectionKey(selectionKey);
--- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java	Thu Apr 28 09:48:54 2016 -0700
@@ -264,7 +264,12 @@
 
             if (connection.shouldRegisterServerReadEvent()) {
                 Selector selector = orb.getTransportManager().getSelector(0);
-                selector.registerForEvent(connection.getEventHandler());
+                if (selector != null) {
+                    if (orb.transportDebugFlag) {
+                        dprint(".accept: registerForEvent: " + connection);
+                    }
+                    selector.registerForEvent(connection.getEventHandler());
+                }
             }
 
             getConnectionCache().reclaim();
@@ -273,12 +278,15 @@
             if (orb.transportDebugFlag) {
                 dprint(".accept:", e);
             }
-            orb.getTransportManager().getSelector(0).unregisterForEvent(this);
-            // REVISIT - need to close - recreate - then register new one.
-            orb.getTransportManager().getSelector(0).registerForEvent(this);
-            // NOTE: if register cycling we do not want to shut down ORB
-            // since local beans will still work.  Instead one will see
-            // a growing log file to alert admin of problem.
+            Selector selector = orb.getTransportManager().getSelector(0);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+                // REVISIT - need to close - recreate - then register new one.
+                selector.registerForEvent(this);
+                // NOTE: if register cycling we do not want to shut down ORB
+                // since local beans will still work.  Instead one will see
+                // a growing log file to alert admin of problem.
+            }
         }
     }
 
@@ -289,7 +297,9 @@
                 dprint(".close->:");
             }
             Selector selector = orb.getTransportManager().getSelector(0);
-            selector.unregisterForEvent(this);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+            }
             if (serverSocketChannel != null) {
                 serverSocketChannel.close();
             }
@@ -480,7 +490,9 @@
             // of calling SelectionKey.interestOps(<interest op>).
 
             Selector selector = orb.getTransportManager().getSelector(0);
-            selector.registerInterestOps(this);
+            if (selector != null) {
+                selector.registerInterestOps(this);
+            }
 
             if (orb.transportDebugFlag) {
                 dprint(".doWork<-:" + this);
--- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java	Thu Apr 28 09:48:54 2016 -0700
@@ -367,7 +367,10 @@
                 }
             }
             // REVISIT - make sure reader thread is killed.
-            orb.getTransportManager().getSelector(0).unregisterForEvent(this);
+            Selector selector = orb.getTransportManager().getSelector(0);
+            if (selector != null) {
+                selector.unregisterForEvent(this);
+            }
             // Notify anyone waiting.
             purgeCalls(wrapper.connectionAbort(ex), true, false);
             // REVISIT
@@ -801,7 +804,9 @@
             }
             try {
                 Selector selector = orb.getTransportManager().getSelector(0);
-                selector.unregisterForEvent(this);
+                if (selector != null) {
+                    selector.unregisterForEvent(this);
+                }
                 if (socketChannel != null) {
                     socketChannel.close();
                 }
@@ -824,7 +829,9 @@
                dprint(".closeConnectionResources->: " + this);
            }
            Selector selector = orb.getTransportManager().getSelector(0);
-           selector.unregisterForEvent(this);
+           if (selector != null) {
+               selector.unregisterForEvent(this);
+           }
            try {
              if (socketChannel != null)
               socketChannel.close() ;
--- a/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java	Mon Apr 11 12:30:18 2016 -0700
+++ b/src/share/classes/com/sun/corba/se/pept/transport/InboundConnectionCache.java	Thu Apr 28 09:48:54 2016 -0700
@@ -36,6 +36,8 @@
     public void put(Acceptor acceptor, Connection connection);
 
     public void remove(Connection connection);
+
+    public Acceptor getAcceptor();
 }
 
 // End of file.