File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 5
5
require 'forwardable'
6
6
require 'fileutils'
7
7
require 'concurrent'
8
+ require_relative 'concurrent/lock'
8
9
9
10
# The class for handling configuration files.
10
11
class Puppet ::Settings
@@ -146,8 +147,21 @@ def initialize
146
147
@configuration_file = nil
147
148
148
149
# And keep a per-environment cache
149
- @cache = Concurrent ::Hash . new { |hash , key | hash [ key ] = Concurrent ::Hash . new }
150
- @values = Concurrent ::Hash . new { |hash , key | hash [ key ] = Concurrent ::Hash . new }
150
+ # We can't use Concurrent::Map because we want to preserve insertion order
151
+ @cache_lock = Puppet ::Concurrent ::Lock . new
152
+ @cache = Concurrent ::Hash . new do |hash , key |
153
+ @cache_lock . synchronize do
154
+ break hash [ key ] if hash . key? ( key )
155
+ hash [ key ] = Concurrent ::Hash . new
156
+ end
157
+ end
158
+ @values_lock = Puppet ::Concurrent ::Lock . new
159
+ @values = Concurrent ::Hash . new do |hash , key |
160
+ @values_lock . synchronize do
161
+ break hash [ key ] if hash . key? ( key )
162
+ hash [ key ] = Concurrent ::Hash . new
163
+ end
164
+ end
151
165
152
166
# The list of sections we've used.
153
167
@used = [ ]
You can’t perform that action at this time.
0 commit comments