Java Code Examples for com.sun.corba.se.pept.transport.Selector#unregisterForEvent()
The following examples show how to use
com.sun.corba.se.pept.transport.Selector#unregisterForEvent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SocketOrChannelConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void closeConnectionResources() { if (orb.transportDebugFlag) { dprint(".closeConnectionResources->: " + this); } Selector selector = orb.getTransportManager().getSelector(0); selector.unregisterForEvent(this); try { if (socketChannel != null) socketChannel.close() ; if (socket != null && !socket.isClosed()) socket.close() ; } catch (IOException e) { if (orb.transportDebugFlag) { dprint( ".closeConnectionResources: " + this, e ) ; } } if (orb.transportDebugFlag) { dprint(".closeConnectionResources<-: " + this); } }
Example 2
Source File: SocketOrChannelConnectionImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
public void closeConnectionResources() { if (orb.transportDebugFlag) { dprint(".closeConnectionResources->: " + this); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } try { if (socketChannel != null) socketChannel.close() ; if (socket != null && !socket.isClosed()) socket.close() ; } catch (IOException e) { if (orb.transportDebugFlag) { dprint( ".closeConnectionResources: " + this, e ) ; } } if (orb.transportDebugFlag) { dprint(".closeConnectionResources<-: " + this); } }
Example 3
Source File: SocketOrChannelAcceptorImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void close () { try { if (orb.transportDebugFlag) { dprint(".close->:"); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (serverSocketChannel != null) { serverSocketChannel.close(); } if (serverSocket != null) { serverSocket.close(); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close:", e); } } finally { if (orb.transportDebugFlag) { dprint(".close<-:"); } } }
Example 4
Source File: SocketOrChannelConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void closeConnectionResources() { if (orb.transportDebugFlag) { dprint(".closeConnectionResources->: " + this); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } try { if (socketChannel != null) socketChannel.close() ; if (socket != null && !socket.isClosed()) socket.close() ; } catch (IOException e) { if (orb.transportDebugFlag) { dprint( ".closeConnectionResources: " + this, e ) ; } } if (orb.transportDebugFlag) { dprint(".closeConnectionResources<-: " + this); } }
Example 5
Source File: SocketOrChannelConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void closeConnectionResources() { if (orb.transportDebugFlag) { dprint(".closeConnectionResources->: " + this); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } try { if (socketChannel != null) socketChannel.close() ; if (socket != null && !socket.isClosed()) socket.close() ; } catch (IOException e) { if (orb.transportDebugFlag) { dprint( ".closeConnectionResources: " + this, e ) ; } } if (orb.transportDebugFlag) { dprint(".closeConnectionResources<-: " + this); } }
Example 6
Source File: SocketOrChannelAcceptorImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void close () { try { if (orb.transportDebugFlag) { dprint(".close->:"); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (serverSocketChannel != null) { serverSocketChannel.close(); } if (serverSocket != null) { serverSocket.close(); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close:", e); } } finally { if (orb.transportDebugFlag) { dprint(".close<-:"); } } }
Example 7
Source File: SocketOrChannelAcceptorImpl.java From JDKSourceCode1.8 with MIT License | 6 votes |
public void close () { try { if (orb.transportDebugFlag) { dprint(".close->:"); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (serverSocketChannel != null) { serverSocketChannel.close(); } if (serverSocket != null) { serverSocket.close(); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close:", e); } } finally { if (orb.transportDebugFlag) { dprint(".close<-:"); } } }
Example 8
Source File: SocketOrChannelConnectionImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
public void closeConnectionResources() { if (orb.transportDebugFlag) { dprint(".closeConnectionResources->: " + this); } Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } try { if (socketChannel != null) socketChannel.close() ; if (socket != null && !socket.isClosed()) socket.close() ; } catch (IOException e) { if (orb.transportDebugFlag) { dprint( ".closeConnectionResources: " + this, e ) ; } } if (orb.transportDebugFlag) { dprint(".closeConnectionResources<-: " + this); } }
Example 9
Source File: SocketOrChannelConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
protected CorbaMessageMediator readBits() { try { if (orb.transportDebugFlag) { dprint(".readBits->: " + this); } MessageMediator messageMediator; // REVISIT - use common factory base class. if (contactInfo != null) { messageMediator = contactInfo.createMessageMediator(orb, this); } else if (acceptor != null) { messageMediator = acceptor.createMessageMediator(orb, this); } else { throw new RuntimeException("SocketOrChannelConnectionImpl.readBits"); } return (CorbaMessageMediator) messageMediator; } catch (ThreadDeath td) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": ThreadDeath: " + td, td); } try { purgeCalls(wrapper.connectionAbort(td), false, false); } catch (Throwable t) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": purgeCalls: Throwable: " + t, t); } } throw td; } catch (Throwable ex) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": Throwable: " + ex, ex); } try { if (ex instanceof INTERNAL) { sendMessageError(GIOPVersion.DEFAULT_VERSION); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": sendMessageError: IOException: " + e, e); } } // REVISIT - make sure reader thread is killed. Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } // Notify anyone waiting. purgeCalls(wrapper.connectionAbort(ex), true, false); // REVISIT //keepRunning = false; // REVISIT - if this is called after purgeCalls then // the state of the socket is ABORT so the writeLock // in close throws an exception. It is ignored but // causes IBM (screen scraping) tests to fail. //close(); } finally { if (orb.transportDebugFlag) { dprint(".readBits<-: " + this); } } return null; }
Example 10
Source File: SocketOrChannelConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 11
Source File: SocketOrChannelConnectionImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
protected CorbaMessageMediator readBits() { try { if (orb.transportDebugFlag) { dprint(".readBits->: " + this); } MessageMediator messageMediator; // REVISIT - use common factory base class. if (contactInfo != null) { messageMediator = contactInfo.createMessageMediator(orb, this); } else if (acceptor != null) { messageMediator = acceptor.createMessageMediator(orb, this); } else { throw new RuntimeException("SocketOrChannelConnectionImpl.readBits"); } return (CorbaMessageMediator) messageMediator; } catch (ThreadDeath td) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": ThreadDeath: " + td, td); } try { purgeCalls(wrapper.connectionAbort(td), false, false); } catch (Throwable t) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": purgeCalls: Throwable: " + t, t); } } throw td; } catch (Throwable ex) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": Throwable: " + ex, ex); } try { if (ex instanceof INTERNAL) { sendMessageError(GIOPVersion.DEFAULT_VERSION); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": sendMessageError: IOException: " + e, e); } } // REVISIT - make sure reader thread is killed. Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } // Notify anyone waiting. purgeCalls(wrapper.connectionAbort(ex), true, false); // REVISIT //keepRunning = false; // REVISIT - if this is called after purgeCalls then // the state of the socket is ABORT so the writeLock // in close throws an exception. It is ignored but // causes IBM (screen scraping) tests to fail. //close(); } finally { if (orb.transportDebugFlag) { dprint(".readBits<-: " + this); } } return null; }
Example 12
Source File: SocketOrChannelConnectionImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); selector.unregisterForEvent(this); if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 13
Source File: SocketOrChannelConnectionImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 14
Source File: SocketOrChannelConnectionImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
protected CorbaMessageMediator readBits() { try { if (orb.transportDebugFlag) { dprint(".readBits->: " + this); } MessageMediator messageMediator; // REVISIT - use common factory base class. if (contactInfo != null) { messageMediator = contactInfo.createMessageMediator(orb, this); } else if (acceptor != null) { messageMediator = acceptor.createMessageMediator(orb, this); } else { throw new RuntimeException("SocketOrChannelConnectionImpl.readBits"); } return (CorbaMessageMediator) messageMediator; } catch (ThreadDeath td) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": ThreadDeath: " + td, td); } try { purgeCalls(wrapper.connectionAbort(td), false, false); } catch (Throwable t) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": purgeCalls: Throwable: " + t, t); } } throw td; } catch (Throwable ex) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": Throwable: " + ex, ex); } try { if (ex instanceof INTERNAL) { sendMessageError(GIOPVersion.DEFAULT_VERSION); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": sendMessageError: IOException: " + e, e); } } // REVISIT - make sure reader thread is killed. Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } // Notify anyone waiting. purgeCalls(wrapper.connectionAbort(ex), true, false); // REVISIT //keepRunning = false; // REVISIT - if this is called after purgeCalls then // the state of the socket is ABORT so the writeLock // in close throws an exception. It is ignored but // causes IBM (screen scraping) tests to fail. //close(); } finally { if (orb.transportDebugFlag) { dprint(".readBits<-: " + this); } } return null; }
Example 15
Source File: SocketOrChannelConnectionImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 16
Source File: SocketOrChannelConnectionImpl.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); selector.unregisterForEvent(this); if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 17
Source File: SocketOrChannelConnectionImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 18
Source File: SocketOrChannelConnectionImpl.java From hottub with GNU General Public License v2.0 | 4 votes |
protected CorbaMessageMediator readBits() { try { if (orb.transportDebugFlag) { dprint(".readBits->: " + this); } MessageMediator messageMediator; // REVISIT - use common factory base class. if (contactInfo != null) { messageMediator = contactInfo.createMessageMediator(orb, this); } else if (acceptor != null) { messageMediator = acceptor.createMessageMediator(orb, this); } else { throw new RuntimeException("SocketOrChannelConnectionImpl.readBits"); } return (CorbaMessageMediator) messageMediator; } catch (ThreadDeath td) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": ThreadDeath: " + td, td); } try { purgeCalls(wrapper.connectionAbort(td), false, false); } catch (Throwable t) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": purgeCalls: Throwable: " + t, t); } } throw td; } catch (Throwable ex) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": Throwable: " + ex, ex); } try { if (ex instanceof INTERNAL) { sendMessageError(GIOPVersion.DEFAULT_VERSION); } } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".readBits: " + this + ": sendMessageError: IOException: " + e, e); } } // REVISIT - make sure reader thread is killed. Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } // Notify anyone waiting. purgeCalls(wrapper.connectionAbort(ex), true, false); // REVISIT //keepRunning = false; // REVISIT - if this is called after purgeCalls then // the state of the socket is ABORT so the writeLock // in close throws an exception. It is ignored but // causes IBM (screen scraping) tests to fail. //close(); } finally { if (orb.transportDebugFlag) { dprint(".readBits<-: " + this); } } return null; }
Example 19
Source File: SocketOrChannelConnectionImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); selector.unregisterForEvent(this); if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }
Example 20
Source File: SocketOrChannelConnectionImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * Note:it is possible for this to be called more than once */ public synchronized void close() { try { if (orb.transportDebugFlag) { dprint(".close->: " + this); } writeLock(); // REVISIT It will be good to have a read lock on the reader thread // before we proceed further, to avoid the reader thread (server side) // from processing requests. This avoids the risk that a new request // will be accepted by ReaderThread while the ListenerThread is // attempting to close this connection. if (isBusy()) { // we are busy! writeUnlock(); if (orb.transportDebugFlag) { dprint(".close: isBusy so no close: " + this); } return; } try { try { sendCloseConnection(GIOPVersion.V1_0); } catch (Throwable t) { wrapper.exceptionWhenSendingCloseConnection(t); } synchronized ( stateEvent ){ state = CLOSE_SENT; stateEvent.notifyAll(); } // stop the reader without causing it to do purgeCalls //Exception ex = new Exception(); //reader.stop(ex); // REVISIT // NOTE: !!!!!! // This does writeUnlock(). purgeCalls(wrapper.connectionRebind(), false, true); } catch (Exception ex) { if (orb.transportDebugFlag) { dprint(".close: exception: " + this, ex); } } try { Selector selector = orb.getTransportManager().getSelector(0); if (selector != null) { selector.unregisterForEvent(this); } if (socketChannel != null) { socketChannel.close(); } socket.close(); } catch (IOException e) { if (orb.transportDebugFlag) { dprint(".close: " + this, e); } } closeConnectionResources(); } finally { if (orb.transportDebugFlag) { dprint(".close<-: " + this); } } }