diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-04 09:52:42 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-04 09:52:42 -0800 |
commit | f474f98750fe70e0264bf80793e578b739c08206 (patch) | |
tree | 7e32faf25ffb245077fd30f10a08c36ad24b5ce3 /lib | |
parent | 86e1c9c9f1ab68977b753b4a2ad496cda8a695a1 (diff) | |
parent | baefdba8fb1a82fc808824cb828638385e9d873b (diff) | |
download | chef-f474f98750fe70e0264bf80793e578b739c08206.tar.gz |
Merge pull request #4130 from chef/lcg/lazy-socketless-require
lazy the socketless require in Chef::HTTP
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/http.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/http.rb b/lib/chef/http.rb index b874491c93..4f08dc90b2 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -5,7 +5,7 @@ # Author:: Christopher Brown (<cb@opscode.com>) # Author:: Christopher Walters (<cw@opscode.com>) # Author:: Daniel DeLeo (<dan@opscode.com>) -# Copyright:: Copyright (c) 2009, 2010, 2013 Opscode, Inc. +# Copyright:: Copyright (c) 2009, 2010, 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +25,6 @@ require 'tempfile' require 'net/https' require 'uri' require 'chef/http/basic_client' -require 'chef/http/socketless_chef_zero_client' require 'chef/monkey_patches/net_http' require 'chef/config' require 'chef/platform/query_helpers' @@ -198,6 +197,14 @@ class Chef def http_client(base_url=nil) base_url ||= url if chef_zero_uri?(base_url) + # 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. + 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) |