summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-10-16 20:04:57 +0200
committerJames Turnbull <james@lovedthanlost.net>2010-11-12 04:03:41 +1100
commitf57425da6aeefd4ff019068c5933add0d2a02f87 (patch)
tree6bc0d9825f24a09b369ba2ed5e17474b43e59420 /lib/puppet
parent9604f1c4cd5a368da08c6f3219b44908a9b9921c (diff)
downloadpuppet-f57425da6aeefd4ff019068c5933add0d2a02f87.tar.gz
puppet-f57425da6aeefd4ff019068c5933add0d2a02f87.tar.xz
puppet-f57425da6aeefd4ff019068c5933add0d2a02f87.zip
Fix #4921 - race condition in Parser Functions creation
The autoloading is not thread safe, which means two threads could both autoload the same function at the same time. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/functions.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index b0deac5bc..5807c0bbe 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -73,8 +73,10 @@ module Puppet::Parser::Functions
def self.function(name)
name = symbolize(name)
- unless functions.include?(name) or functions(Puppet::Node::Environment.root).include?(name)
- autoloader.load(name,Environment.current || Environment.root)
+ @functions.synchronize do
+ unless functions.include?(name) or functions(Puppet::Node::Environment.root).include?(name)
+ autoloader.load(name,Environment.current || Environment.root)
+ end
end
( functions(Environment.root)[name] || functions[name] || {:name => false} )[:name]