diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-03 13:13:37 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-04 08:01:36 -0800 |
commit | baefdba8fb1a82fc808824cb828638385e9d873b (patch) | |
tree | a1cd710481c8a3a290a093052c8a6b4d9f53c518 /lib/chef/http.rb | |
parent | 40db8612b99c177ea24b181cbb0bf849f4748601 (diff) | |
download | chef-baefdba8fb1a82fc808824cb828638385e9d873b.tar.gz |
thread-safe performant lazy requirelcg/lazy-socketless-require
Diffstat (limited to 'lib/chef/http.rb')
-rw-r--r-- | lib/chef/http.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 8fa2569190..0d0abdddd8 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -200,7 +200,11 @@ class Chef # PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick # via chef-zero and that hits DNS (at *require* time) which may timeout, # when for most knife/chef-client work we never need/want this loaded. - require 'chef/http/socketless_chef_zero_client' + Thread.exclusive { + unless defined?(SocketlessChefZeroClient) + require 'chef/http/socketless_chef_zero_client' + end + } SocketlessChefZeroClient.new(base_url) else BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy) |