From 4627b8fe11dc14bf42e98b84121b885df73c709e Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Mon, 14 Jun 2010 18:22:40 -0700 Subject: Improving fix for #1175; tightening thread safety The previous code maintained thread safety up to work-duplication (so that a collision would, at worse, result in effective cache flushing and cause some additional work to be done). The preceding patch addressed the single thread issue of environment specific functions; this patch brings the thread safety up to the previous standard. --- lib/puppet/node/environment.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/puppet/node') diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 4363eea41..81f8f2cfe 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -42,15 +42,15 @@ class Puppet::Node::Environment end def self.current - @current || root + Thread.current[:environment] || root end def self.current=(env) - @current = new(env) + Thread.current[:environment] = new(env) end def self.root - @root ||= new(:'*root*') + @root end # This is only used for testing. @@ -128,4 +128,5 @@ class Puppet::Node::Environment end end + @root = new(:'*root*') end -- cgit