summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-04-22 12:20:05 +0300
committerSaku Ytti <saku@ytti.fi>2014-04-22 12:20:05 +0300
commit09dfc11b5dfdfe926b217c17549e417b79009d7d (patch)
tree725a12bd05b8a26bf8cc6c49d8b1aa652cc84ddb
parentda959461a6f90856d5d3d02e26d32d7d4c0a4c2c (diff)
potential fix to race condition
1) ssh fails 2) user clicks 'update' 3) node is reset and moved head of queue 4) telnet fails 5) node last time is set to current net result, head of queue will block until interval has passed, even though below head there are nodes which need to be processed.
-rw-r--r--Rakefile5
-rw-r--r--lib/oxidized/nodes.rb14
-rw-r--r--oxidized.gemspec2
3 files changed, 16 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index 2e3c604..d0e8c23 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,9 @@
begin
require 'rake/testtask'
require 'bundler'
- Bundler.setup
+ # Bundler.setup
rescue LoadError
warn 'bunler missing'
- exit 42
end
gemspec = eval(File.read(Dir['*.gemspec'].first))
@@ -33,7 +32,7 @@ end
desc 'Install gem'
task :install => :build do
- system "sudo -E sh -c \'umask 022; gem install gems/#{file}\'"
+ system "sudo -Es sh -c \'umask 022; gem install gems/#{file}\'"
end
desc 'Remove gems'
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 213f534..4ceee31 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -61,8 +61,9 @@ module Oxidized
# @param node [String] name of the node moved into the head of array
def next node, opt={}
with_lock do
- n = del node
+ n = running.del node
if n
+ n = del node
n.user = opt['user']
n.msg = opt['msg']
n.from = opt['from']
@@ -80,6 +81,17 @@ module Oxidized
end
end
+ # @return [Array] list of nodes running now
+ def running
+ select { |node| node.running? }
+ end
+
+ # @return [Array] list of nodes waiting (not running)
+ def waiting
+ select { |node| not node.running? }
+ end
+
+
private
def initialize opts={}
diff --git a/oxidized.gemspec b/oxidized.gemspec
index 1145bd7..e3da1df 100644
--- a/oxidized.gemspec
+++ b/oxidized.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'oxidized'
- s.version = '0.0.54'
+ s.version = '0.0.55'
s.platform = Gem::Platform::RUBY
s.authors = [ 'Saku Ytti' ]
s.email = %w( saku@ytti.fi )