summaryrefslogtreecommitdiff
path: root/lib/rubygems/remote_fetcher.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r--lib/rubygems/remote_fetcher.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index ec052b50da..86bad9de41 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -1,5 +1,6 @@
require 'rubygems'
require 'rubygems/user_interaction'
+require 'thread'
require 'uri'
require 'resolv'
@@ -72,6 +73,7 @@ class Gem::RemoteFetcher
Socket.do_not_reverse_lookup = true
@connections = {}
+ @connections_mutex = Mutex.new
@requests = Hash.new 0
@proxy_uri =
case proxy
@@ -391,8 +393,11 @@ class Gem::RemoteFetcher
end
connection_id = [Thread.current.object_id, *net_http_args].join ':'
- @connections[connection_id] ||= Net::HTTP.new(*net_http_args)
- connection = @connections[connection_id]
+
+ connection = @connections_mutex.synchronize do
+ @connections[connection_id] ||= Net::HTTP.new(*net_http_args)
+ @connections[connection_id]
+ end
if https?(uri) and not connection.started? then
configure_connection_for_https(connection)