Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ appear at the top.

* Add your entries below here, remember to credit yourself however you want
to be credited!
* SSHKit now explicitly closes its pooled SSH connections when Ruby exits;
this fixes `zlib(finalizer): the stream was freed prematurely` warnings
[PR #343](https://github.com/capistrano/sshkit/pull/343) @mattbrictson
* Allow command map entries (`SSHKit::CommandMap#[]`) to be Procs
[PR #310]((https://github.com/capistrano/sshkit/pull/310)
@mikz
Expand Down
6 changes: 6 additions & 0 deletions lib/sshkit/backends/netssh.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'English'
require 'net/ssh'
require 'net/scp'

Expand Down Expand Up @@ -44,7 +45,12 @@ def download!(remote, local=nil, options = {})
end
end

# Note that this pool must be explicitly closed before Ruby exits to
# ensure the underlying IO objects are properly cleaned up. We register an
# at_exit handler to do this automatically, as long as Ruby is exiting
# cleanly (i.e. without an exception).
@pool = SSHKit::Backend::ConnectionPool.new
at_exit { @pool.close_connections if @pool && !$ERROR_INFO }

class << self
attr_accessor :pool
Expand Down