Mercurial > 510Connectbot
diff src/ch/ethz/ssh2/transport/TransportManager.java @ 319:776a220dbcc6 ganymed
add ecdsa key support everywhere
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 31 Jul 2014 08:20:47 -0700 |
parents | 071eccdff8ea |
children | 5afb8c1a54b9 |
line wrap: on
line diff
--- a/src/ch/ethz/ssh2/transport/TransportManager.java Wed Jul 30 17:46:06 2014 -0700 +++ b/src/ch/ethz/ssh2/transport/TransportManager.java Thu Jul 31 08:20:47 2014 -0700 @@ -162,30 +162,47 @@ return km.sessionId; } - public void close() { - // It is safe now to acquire the semaphore. + public void close(Throwable cause, boolean useDisconnectPacket) { + if (useDisconnectPacket == false) { + // OK, hard shutdown - do not acquire the semaphore, + // perhaps somebody is inside (and waits until + // the remote side is ready to accept new data). + try { + socket.close(); + } + catch (IOException ignore) { + } + // OK, whoever tried to send data, should now agree that + // there is no point in further waiting =) + // It is safe now to acquire the semaphore. + } + synchronized (connectionSemaphore) { if (!connectionClosed) { - try { - tc.sendMessage(new PacketDisconnect( - PacketDisconnect.Reason.SSH_DISCONNECT_BY_APPLICATION, "").getPayload()); - } - catch (IOException ignore) { - // - } + if (useDisconnectPacket == true) { + try { + if (tc != null) + tc.sendMessage(new PacketDisconnect(PacketDisconnect.Reason.SSH_DISCONNECT_BY_APPLICATION, "").getPayload()); + } + catch (IOException ignore) { + } - try { - socket.close(); - } - catch (IOException ignore) { - // - } + try { + socket.close(); + } + catch (IOException ignore) { + } - connectionClosed = true; + connectionClosed = true; + reasonClosedCause = cause; synchronized (this) { for (ConnectionMonitor cmon : connectionMonitors) { - cmon.connectionLost(reasonClosedCause); + try { + cmon.connectionLost(reasonClosedCause); + } + catch (Exception ignore) { + } } } } @@ -194,29 +211,6 @@ } } - public void close(IOException cause) { - // Do not acquire the semaphore, perhaps somebody is inside (and waits until - // the remote side is ready to accept new data - try { - socket.close(); - } - catch (IOException ignore) { - } - - // It is safe now to acquire the semaphore. - synchronized (connectionSemaphore) { - connectionClosed = true; - reasonClosedCause = cause; - connectionSemaphore.notifyAll(); - } - - synchronized (this) { - for (ConnectionMonitor cmon : connectionMonitors) { - cmon.connectionLost(reasonClosedCause); - } - } - } - protected void startReceiver() throws IOException { final Thread receiveThread = new Thread(new Runnable() { public void run() {