/** * Destroy the socket manager, freeing all the associated resources. This method will block until * all the managed sockets are closed. * * <p>CANNOT be restarted. */ public void destroySocketManager() { if (!_isDestroyed.compareAndSet(false, true)) { // shouldn't happen, log a stack trace to find out why it happened _log.logCloseLoop("I2PSocketManager", getName()); return; } _connectionManager.setAllowIncomingConnections(false); _connectionManager.shutdown(); if (!_subsessions.isEmpty()) { for (I2PSession sess : _subsessions) { removeSubsession(sess); } } // should we destroy the _session too? // yes, since the old lib did (and SAM wants it to, and i dont know why not) if ((_session != null) && (!_session.isClosed())) { try { _session.destroySession(); } catch (I2PSessionException ise) { _log.warn("Unable to destroy the session", ise); } PcapWriter pcap = null; synchronized (_pcapInitLock) { pcap = pcapWriter; } if (pcap != null) pcap.flush(); } }