lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.7.1 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.8.0
- old
+ new
@@ -32,10 +32,11 @@
end
def initialize
reset_to_defaults
@callbacks = Hash.new { |hash, key| hash[key] = [] }
+ @lock = Mutex.new
end
def add_config_for_testing(source, level = 0)
raise 'Invalid config type for testing' unless [Hash, DottedHash].include?(source.class)
@@ -362,12 +363,14 @@
# reset the configuration hash, but do not replace previously auto
# determined dependency detection values with nil or 'auto'
def reset_cache
return new_cache unless defined?(@cache) && @cache
- preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
- new_cache
- preserved.each { |k, v| @cache[k] = v }
+ @lock.synchronize do
+ preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
+ new_cache
+ preserved.each { |k, v| @cache[k] = v }
+ end
@cache
end
def new_cache