+1. It seems like I've smashed into this line of code three times in the
last week.

On Sun, Jul 11, 2010 at 12:24 PM, Markus Roberts <[email protected]> wrote:

> 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
>
> Signed-off-by: Markus Roberts <[email protected]>
> ---
>  lib/puppet/parser/type_loader.rb |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/puppet/parser/type_loader.rb
> b/lib/puppet/parser/type_loader.rb
> index 6c32f6a..cb8657f 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
> --
> 1.6.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<puppet-dev%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/puppet-dev?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to