diff options
author | Luke Kanies <luke@madstop.com> | 2007-12-17 17:13:25 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-12-17 17:13:25 -0600 |
commit | 933b1df6d84ec34a6ff347240c0151434ecc80a9 (patch) | |
tree | c02967b3be2880db79af12e685dce03b5ffce2c6 /lib/puppet/network | |
parent | e0dab9a48896f3d92b2845f5a886885ede777305 (diff) | |
download | puppet-933b1df6d84ec34a6ff347240c0151434ecc80a9.tar.gz puppet-933b1df6d84ec34a6ff347240c0151434ecc80a9.tar.xz puppet-933b1df6d84ec34a6ff347240c0151434ecc80a9.zip |
Fixing #961 -- closing existing, open connections when
a new connection is requested, and closing all connections
at the end of each run.
Diffstat (limited to 'lib/puppet/network')
-rw-r--r-- | lib/puppet/network/client/master.rb | 4 | ||||
-rw-r--r-- | lib/puppet/network/xmlrpc/client.rb | 31 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 54b1dcaa4..341192740 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -271,6 +271,10 @@ class Puppet::Network::Client::Master < Puppet::Network::Client @catalog.apply(options) end end + + # Now close all of our existing http connections, since there's no + # reason to leave them lying open. + Puppet::Network::XMLRPCClient.clear_http_instances end lockfile.unlock diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index 5283daf5f..5048a040a 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -19,8 +19,11 @@ module Puppet::Network include Puppet::Util::ClassGen end - # Clear our http cache. + # Clear our http cache, closing all connections. def self.clear_http_instances + @@http_cache.each do |name, connection| + connection.finish if connection.started? + end @@http_cache.clear end @@ -34,31 +37,37 @@ module Puppet::Network # a cache, as long as we're not resetting the instance. return @@http_cache[key] if ! reset and Puppet[:http_keepalive] and @@http_cache[key] + # Clean up old connections if we have them. + if http = @@http_cache[key] + @@http_cache.delete(key) + http.finish if http.started? + end + args = [host, port] if Puppet[:http_proxy_host] == "none" args << nil << nil else args << Puppet[:http_proxy_host] << Puppet[:http_proxy_port] end - @http = Net::HTTP.new(*args) + http = Net::HTTP.new(*args) - # Pop open @http a little; older versions of Net::HTTP(s) didn't + # Pop open the http client a little; older versions of Net::HTTP(s) didn't # give us a reader for ca_file... Grr... - class << @http; attr_accessor :ca_file; end + class << http; attr_accessor :ca_file; end - @http.use_ssl = true - @http.read_timeout = 120 - @http.open_timeout = 120 + http.use_ssl = true + http.read_timeout = 120 + http.open_timeout = 120 # JJM Configurable fix for #896. if Puppet[:http_enable_post_connection_check] - @http.enable_post_connection_check = true + http.enable_post_connection_check = true else - @http.enable_post_connection_check = false + http.enable_post_connection_check = false end - @@http_cache[key] = @http if Puppet[:http_keepalive] + @@http_cache[key] = http if Puppet[:http_keepalive] - return @http + return http end # Create a netclient for each handler |