diff options
author | Jamis Buck <jamis@37signals.com> | 2009-01-31 21:23:26 -0700 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2009-01-31 21:23:26 -0700 |
commit | 07ba76a53e659414d9b9dae17bce8e16d394f333 (patch) | |
tree | 06ef13598bea16a3a8edd71c6d40953a9c610d46 | |
parent | f9b2f3cb8de97730b4b4a5624fdb6e0fd0302f26 (diff) | |
download | net-ssh-07ba76a53e659414d9b9dae17bce8e16d394f333.tar.gz |
Add a terminate! method for hard shutdowns
-rw-r--r-- | CHANGELOG.rdoc | 2 | ||||
-rw-r--r-- | lib/net/ssh/connection/session.rb | 10 | ||||
-rw-r--r-- | lib/net/ssh/transport/session.rb | 11 |
3 files changed, 21 insertions, 2 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 54de5b9..a78ad4b 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -1,5 +1,7 @@ === unreleased +* Add terminate! method for hard shutdown scenarios [Jamis Buck] + * Revert to pre-2.0.7 key-loading behavior by default, but load private-key if public-key doesn't exist [Jamis Buck] * Make sure :passphrase option gets passed to key manager [Bob Cotton] diff --git a/lib/net/ssh/connection/session.rb b/lib/net/ssh/connection/session.rb index 439db4b..eb9b259 100644 --- a/lib/net/ssh/connection/session.rb +++ b/lib/net/ssh/connection/session.rb @@ -100,6 +100,14 @@ module Net; module SSH; module Connection transport.close end + # Performs a "hard" shutdown of the connection. In general, this should + # never be done, but it might be necessary (in a rescue clause, for instance, + # when the connection needs to close but you don't know the status of the + # underlying protocol's state). + def shutdown! + transport.shutdown! + end + # preserve a reference to Kernel#loop alias :loop_forever :loop @@ -575,4 +583,4 @@ module Net; module SSH; module Connection end end -end; end; end
\ No newline at end of file +end; end; end diff --git a/lib/net/ssh/transport/session.rb b/lib/net/ssh/transport/session.rb index 7b42bd2..519777f 100644 --- a/lib/net/ssh/transport/session.rb +++ b/lib/net/ssh/transport/session.rb @@ -104,6 +104,15 @@ module Net; module SSH; module Transport socket.close end + # Performs a "hard" shutdown of the connection. In general, this should + # never be done, but it might be necessary (in a rescue clause, for instance, + # when the connection needs to close but you don't know the status of the + # underlying protocol's state). + def shutdown! + error { "forcing connection closed" } + socket.close + end + # Returns a new service_request packet for the given service name, ready # for sending to the server. def service_request(service) @@ -264,4 +273,4 @@ module Net; module SSH; module Transport end end end -end; end; end
\ No newline at end of file +end; end; end |