diff options
| author | David Lutterkort <dlutter@redhat.com> | 2007-12-17 16:52:54 -0800 |
|---|---|---|
| committer | David Lutterkort <dlutter@redhat.com> | 2007-12-17 16:52:54 -0800 |
| commit | 4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52 (patch) | |
| tree | 9e708ec31ce32909cdc693037d7b6e1f32a06b62 /lib | |
| parent | 8f5989a66b3e9ff3001b50c07a818c6ccb04a65f (diff) | |
| parent | 933b1df6d84ec34a6ff347240c0151434ecc80a9 (diff) | |
| download | puppet-4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52.tar.gz puppet-4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52.tar.xz puppet-4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52.zip | |
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
Diffstat (limited to 'lib')
| -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 |
