aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems/specification.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/specification.rb')
-rw-r--r--lib/rubygems/specification.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb
index 88e30e71b3..abb6e0ecfd 100644
--- a/lib/rubygems/specification.rb
+++ b/lib/rubygems/specification.rb
@@ -109,6 +109,7 @@ class Gem::Specification < Gem::BasicSpecification
# rubocop:disable Style/MutableConstant
LOAD_CACHE = {} # :nodoc:
# rubocop:enable Style/MutableConstant
+ LOAD_CACHE_MUTEX = Mutex.new
private_constant :LOAD_CACHE if defined? private_constant
@@ -753,7 +754,9 @@ class Gem::Specification < Gem::BasicSpecification
end
def self._clear_load_cache # :nodoc:
- LOAD_CACHE.clear
+ LOAD_CACHE_MUTEX.synchronize do
+ LOAD_CACHE.clear
+ end
end
def self.each_gemspec(dirs) # :nodoc:
@@ -1105,7 +1108,7 @@ class Gem::Specification < Gem::BasicSpecification
def self.load(file)
return unless file
- _spec = LOAD_CACHE[file]
+ _spec = LOAD_CACHE_MUTEX.synchronize { LOAD_CACHE[file] }
return _spec if _spec
file = file.dup.untaint
@@ -1120,7 +1123,9 @@ class Gem::Specification < Gem::BasicSpecification
if Gem::Specification === _spec
_spec.loaded_from = File.expand_path file.to_s
- LOAD_CACHE[file] = _spec
+ LOAD_CACHE_MUTEX.synchronize do
+ LOAD_CACHE[file] = _spec
+ end
return _spec
end