diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-28 16:17:46 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-06-28 16:17:46 +0000 |
commit | 547121158f91ace7fe1e0c6f6b7fe0570acbf28c (patch) | |
tree | af2f2e48a41b01b775743fb771f8ff1dd4e64d0d | |
parent | ad1396d3d960b805d3f9510d105937b6854deb90 (diff) | |
download | puppet-547121158f91ace7fe1e0c6f6b7fe0570acbf28c.tar.gz puppet-547121158f91ace7fe1e0c6f6b7fe0570acbf28c.tar.xz puppet-547121158f91ace7fe1e0c6f6b7fe0570acbf28c.zip |
Moving the timer monitoring to after the services are created (because they actually create the timers), and adding a sleep statement to give the threads enough time to create the timers.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1326 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index 7615ec1c7..4514f82d6 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -317,12 +317,15 @@ module Puppet end def self.newtimer(hash, &block) - @timers ||= [] - timer = EventLoop::Timer.new(hash) - @timers << timer - - if block_given? - observe_signal(timer, :alarm, &block) + timer = nil + threadlock(:timers) do + @timers ||= [] + timer = EventLoop::Timer.new(hash) + @timers << timer + + if block_given? + observe_signal(timer, :alarm, &block) + end end # In case they need it for something else. @@ -429,12 +432,7 @@ module Puppet # Start all of our services and optionally our event loop, which blocks, # waiting for someone, somewhere, to generate events of some kind. def self.start(block = true) - #Puppet.info "Starting loop" # Starting everything in its own thread, fwiw - defined? @timers and @timers.each do |timer| - EventLoop.current.monitor_timer timer - end - defined? @services and @services.each do |svc| newthread do begin @@ -454,6 +452,16 @@ module Puppet exit(1) end + # We need to give the services a chance to register their timers before + # we try to start monitoring them. + sleep 0.5 + + if defined? @timers and ! @timers.empty? + @timers.each do |timer| + EventLoop.current.monitor_timer timer + end + end + if block EventLoop.current.run end |