From 1c3e844c120c3c91c63b64c093f94d5dbab7b946 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Sun, 11 Jul 2010 12:12:43 -0700 Subject: Minimal fix for #4205 -- incorrect Import loop messages This patch fixes the narrow problem of #4205, wherein type_loader would reparse a file each time it was imported (causing the parser to incorrectly think that it was in a loop) by checking @imported inside the existing check on the thread-guarded @loaded. (@imported was being set but never checked). This works (and is thread safe) because all of this is going on inside a giant synchronize care of @loaded. But it, like the fix for #4208, does nothing about the global lock. Areas for future research: 1) Why is the looping inside of import? 2) Why are there separate @loaded and @imported tables? 3) Why is the parsing treated like a function (called deep in the structure) yet coded like a thread-savvy pseudo state monad (e.g. raising errors that presume it knows/owns what's going on outside the whole process)? These and many other exciting questions are deferred to #4211 --- lib/puppet/parser/type_loader.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index 6c32f6a92..cb8657f0c 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -51,8 +51,10 @@ class Puppet::Parser::TypeLoader unless file =~ /^#{File::SEPARATOR}/ file = File.join(dir, file) end - @imported[file] = true - parse_file(file) + unless imported? file + @imported[file] = true + parse_file(file) + end end modname -- cgit