summaryrefslogtreecommitdiff
path: root/lib/oxidized/nodes.rb
diff options
context:
space:
mode:
authorSaku Ytti <saku@ytti.fi>2014-04-22 13:03:11 +0300
committerSaku Ytti <saku@ytti.fi>2014-04-22 13:03:11 +0300
commit1a68ed15f20fd6b6128ae9533ec276341b35a530 (patch)
tree64535e0ab2b699433501cd0e71e18e5f1cee0f01 /lib/oxidized/nodes.rb
parent723baec6cb89b1a129b3db5f3df2c5a986a8be5c (diff)
we can't lock 'del', it's called from locked 'next'0.0.55
Diffstat (limited to 'lib/oxidized/nodes.rb')
-rw-r--r--lib/oxidized/nodes.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb
index 24f52aa..46630b8 100644
--- a/lib/oxidized/nodes.rb
+++ b/lib/oxidized/nodes.rb
@@ -60,9 +60,8 @@ module Oxidized
# @param node [String] name of the node moved into the head of array
def next node, opt={}
- with_lock do
- n = waiting.del node
- if n
+ if waiting.find_node_index(node)
+ with_lock do
n = del node
n.user = opt['user']
n.msg = opt['msg']
@@ -82,12 +81,10 @@ module Oxidized
end
end
- # @param node node which is removed from nodes list
- # @return [Node] deleted node
- def del node
- with_lock do
- delete_at find_node_index(node)
- end
+ # @param node node whose index number in Nodes to find
+ # @return [Fixnum] index number of node in Nodes
+ def find_node_index node
+ find_index node or raise Oxidized::NodeNotFound, "unable to find '#{node}'"
end
private
@@ -111,8 +108,10 @@ module Oxidized
index { |e| e.name == node }
end
- def find_node_index node
- find_index node or raise Oxidized::NodeNotFound, "unable to find '#{node}'"
+ # @param node node which is removed from nodes list
+ # @return [Node] deleted node
+ def del node
+ delete_at find_node_index(node)
end
# @return [Nodes] list of nodes running now