diff options
author | Luke Kanies <luke@madstop.com> | 2008-03-21 00:26:08 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-03-21 00:26:08 -0500 |
commit | f6325dceb3b10c300f421f540281bbd64bdc091e (patch) | |
tree | db3ae0d91d53e0f4a8a3815d891e04271e4a19d7 /lib/puppet/parser/parser_support.rb | |
parent | 25b81b386b3581c1afb8c1ffcd23e2b1953472b4 (diff) | |
download | puppet-f6325dceb3b10c300f421f540281bbd64bdc091e.tar.gz puppet-f6325dceb3b10c300f421f540281bbd64bdc091e.tar.xz puppet-f6325dceb3b10c300f421f540281bbd64bdc091e.zip |
Found an array that leaked pretty quickly between reparsing
files, thanks to work by Adam Jacob and Arjuna Christenson
(the finding, not the leak). I'm going to act like this
fixes #1131, at least for now, but I doubt it does,
since that shows general memory growth over time, whereas
the leak here should go away as soon as files are reparsed
(because the parser is holding the reference to the leaking
array).
Diffstat (limited to 'lib/puppet/parser/parser_support.rb')
-rw-r--r-- | lib/puppet/parser/parser_support.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index ccfc4d48a..b86a4792b 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -123,13 +123,17 @@ class Puppet::Parser::Parser def fqfind(namespace, name, table) namespace = namespace.downcase name = name.to_s.downcase + + # If our classname is fully qualified or we have no namespace, + # just try directly for the class, and return either way. if name =~ /^::/ or namespace == "" classname = name.sub(/^::/, '') - unless table[classname] - self.load(classname) - end + self.load(classname) unless table[classname] return table[classname] end + + # Else, build our namespace up piece by piece, checking + # for the class in each namespace. ary = namespace.split("::") while ary.length > 0 @@ -221,7 +225,6 @@ class Puppet::Parser::Parser return false if classname == "" filename = classname.gsub("::", File::SEPARATOR) - loaded = false # First try to load the top-level module mod = filename.scan(/^[\w-]+/).shift unless @loaded.include?(mod) @@ -229,24 +232,24 @@ class Puppet::Parser::Parser begin import(mod) Puppet.info "Autoloaded module %s" % mod - loaded = true rescue Puppet::ImportError => detail # We couldn't load the module end end - unless filename == mod and ! @loaded.include?(mod) - @loaded << mod + return true if classes.include?(classname) + + unless @loaded.include?(filename) + @loaded << filename # Then the individual file begin import(filename) Puppet.info "Autoloaded file %s from module %s" % [filename, mod] - loaded = true rescue Puppet::ImportError => detail # We couldn't load the file end end - return loaded + return classes.include?(classname) end # Split an fq name into a namespace and name |