Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Add option for close_on_exit
Browse files Browse the repository at this point in the history
Added an option (close_on_exit) to only add the at_exit to close the
connection if desired. To prevent breaking existing code relying on
this, the option defaults to true (keeping existing
functionality). Setting to false will prevent the at_exit from being
added which will solve existing cases of memory leaks.

Closes #154
Fixes #156
  • Loading branch information
seandilda authored and jrgarcia committed Apr 17, 2019
1 parent 893e413 commit cd09d58
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rbvmomi/vim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class VIM < Connection
# @option opts [String] :path (/sdk) SDK endpoint path.
# @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr.
# @option opts [String] :operation_id If set, use for operationID
# @option opts [Boolean] :close_on_exit (true) If true, will close connection with at_exit
def self.connect opts
fail unless opts.is_a? Hash
fail "host option required" unless opts[:host]
Expand Down Expand Up @@ -64,7 +65,7 @@ def self.connect opts
vim.rev = [rev, opts[:rev]].min { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
end

at_exit { conn.close }
at_exit { conn.close } if opts.fetch(:close_on_exit, true)
conn
end

Expand Down

0 comments on commit cd09d58

Please sign in to comment.