diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-19 19:39:26 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-19 19:39:26 +0000 |
commit | 290ad14f50dcb6e530e6f2624fe05d1c4cac3538 (patch) | |
tree | a0692b96035eaa97ad61abaf09fd72261a9464b9 /lib/puppet | |
parent | 32662cb32365a10901bdee81fcf3e8480ebf607b (diff) | |
download | puppet-290ad14f50dcb6e530e6f2624fe05d1c4cac3538.tar.gz puppet-290ad14f50dcb6e530e6f2624fe05d1c4cac3538.tar.xz puppet-290ad14f50dcb6e530e6f2624fe05d1c4cac3538.zip |
Finally fixing #504, I think; I even have tests to prove it. It was a little thing, in the end.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2326 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/network/client/master.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index a75410256..7feebd2e6 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -105,6 +105,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client def clear @objects.remove(true) Puppet::Type.allclear + mkdefault_objects @objects = nil end @@ -156,12 +157,12 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # Let the daemon run again, freely in the filesystem. Frolick, little # daemon! def enable - Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]).unlock(:anonymous => true) + lockfile.unlock(:anonymous => true) end # Stop the daemon from making any configuration runs. def disable - Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]).lock(:anonymous => true) + lockfile.lock(:anonymous => true) end # Retrieve the config from a remote server. If this fails, then @@ -286,15 +287,13 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # The code that actually runs the configuration. def run(tags = nil, ignoreschedules = false) - lockfile = Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]) - - locked = false + got_lock = false Puppet::Util.sync(:puppetrun).synchronize(Sync::EX) do if !lockfile.lock Puppet.notice "Lock file %s exists; skipping configuration run" % lockfile.lockfile else - @running = true + got_lock = true @configtime = thinmark do self.getconfig end @@ -307,7 +306,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client self.apply(tags, ignoreschedules) end end - @running = false end lockfile.unlock @@ -320,11 +318,11 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end ensure # Just make sure we remove the lock file if we set it. - lockfile.unlock if locked and lockfile.locked? + lockfile.unlock if got_lock and lockfile.locked? end def running? - @running + lockfile.locked? end # Store the classes in the classfile, but only if we're not local. @@ -626,6 +624,14 @@ class Puppet::Network::Client::Master < Puppet::Network::Client return objects end + + def lockfile + unless defined?(@lockfile) + @lockfile = Puppet::Util::Pidlock.new(Puppet[:puppetdlockfile]) + end + + @lockfile + end end # $Id$ |