From 70e84021f222275f12e91302aab95aeb0a59ea4f Mon Sep 17 00:00:00 2001 From: jabber Date: Sun, 17 Apr 2011 06:05:48 +0400 Subject: [PATCH] Remove global lock if there are no nodes available --- src/ejabberd_cluster.erl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ejabberd_cluster.erl b/src/ejabberd_cluster.erl index e537e1faa..bc2f85da6 100644 --- a/src/ejabberd_cluster.erl +++ b/src/ejabberd_cluster.erl @@ -136,9 +136,13 @@ handle_call(announce, _From, State) -> {node_ready, node()}, ?REHASH_TIMEOUT), append_node(?HASHTBL, node()), register(?MODULE, self()), - gen_server:abcast(OtherNodes -- BadNodes, - ?MODULE, {node_ready, node()}), - erlang:send_after(?MIGRATE_TIMEOUT, self(), del_lock) + case OtherNodes -- BadNodes of + [] -> + global:del_lock(?LOCK); + WorkingNodes -> + gen_server:abcast(WorkingNodes, ?MODULE, {node_ready, node()}), + erlang:send_after(?MIGRATE_TIMEOUT, self(), del_lock) + end end, {reply, ok, State}; handle_call({node_ready, Node}, _From, State) ->