From 09dfc11b5dfdfe926b217c17549e417b79009d7d Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Tue, 22 Apr 2014 12:20:05 +0300 Subject: 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. --- lib/oxidized/nodes.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/oxidized') 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={} -- cgit v1.2.1