From 1a68ed15f20fd6b6128ae9533ec276341b35a530 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Tue, 22 Apr 2014 13:03:11 +0300 Subject: we can't lock 'del', it's called from locked 'next' --- lib/oxidized/nodes.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib/oxidized') 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 -- cgit v1.2.1