diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2010-10-16 20:04:57 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2010-11-12 04:03:41 +1100 |
commit | f57425da6aeefd4ff019068c5933add0d2a02f87 (patch) | |
tree | 6bc0d9825f24a09b369ba2ed5e17474b43e59420 /spec | |
parent | 9604f1c4cd5a368da08c6f3219b44908a9b9921c (diff) | |
download | puppet-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 'spec')
-rw-r--r-- | spec/integration/parser/functions_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/integration/parser/functions_spec.rb b/spec/integration/parser/functions_spec.rb new file mode 100644 index 000000000..cbfb4ac88 --- /dev/null +++ b/spec/integration/parser/functions_spec.rb @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe Puppet::Parser::Functions do + before :each do + Puppet::Parser::Functions.rmfunction("template") if Puppet::Parser::Functions.function("template") + end + + it "should support multiple threads autoloading the same function" do + threads = [] + lambda { + 10.times { |a| + threads << Thread.new { + Puppet::Parser::Functions.function("template") + } + } + }.should_not raise_error + threads.each { |t| t.join } + end +end
\ No newline at end of file |