src/java.corba/share/classes/com/sun/corba/se/impl/transport/SelectorImpl.java

Print this page

        

*** 24,43 **** --- 24,46 ---- */ 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.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; import com.sun.corba.se.pept.transport.EventHandler; import com.sun.corba.se.pept.transport.ListenerThread;
*** 237,246 **** --- 240,251 ---- while (i.hasNext()) { ReaderThread readerThread = (ReaderThread) i.next(); readerThread.close(); } + clearDeferredRegistrations(); + // Selector try { if (selector != null) { // wakeup Selector thread to process close request
*** 326,335 **** --- 331,385 ---- ///////////////////////////////////////////////////// // // 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(); + if (channel instanceof ServerSocketChannel) { + dprint(".clearDeferredRegistrations:close ServerSocketCHannel == " + + channel); + ServerSocket ss = ((ServerSocketChannel) channel) + .socket(); + ss.close(); + selectionKey = eventHandler.getSelectionKey(); + if (selectionKey != null) { + selectionKey.cancel(); + selectionKey.attach(null); + } + } + } catch (IOException ioEx) { + if (orb.transportDebugFlag) { + dprint(".handleDeferredRegistrations: " + ioEx); + } + } + } + deferredRegistrations.clear(); + } + } + private synchronized boolean isClosed () { return closed; }