summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2013-03-22 14:40:47 +0000
committerSimon MacMullen <simon@rabbitmq.com>2013-03-22 14:40:47 +0000
commit24667bfce161c25bfca584e85d3ebec65156930e (patch)
tree4ac78a986f298c7f584ddd4ab521c551dc60d9b1
parentab88adcf3163b7b4ebd93306eb900490be433516 (diff)
downloadrabbitmq-server-bug25499.tar.gz
Check if the rabbit process is running and thus avoid deadlocks in the application controller.bug25499
-rw-r--r--src/rabbit_node_monitor.erl2
-rw-r--r--src/rabbit_nodes.erl11
2 files changed, 11 insertions, 2 deletions
diff --git a/src/rabbit_node_monitor.erl b/src/rabbit_node_monitor.erl
index 3872f3df..263f960d 100644
--- a/src/rabbit_node_monitor.erl
+++ b/src/rabbit_node_monitor.erl
@@ -319,7 +319,7 @@ alive_nodes() ->
[N || N <- Nodes, pong =:= net_adm:ping(N)].
alive_rabbit_nodes() ->
- [N || N <- alive_nodes(), rabbit_nodes:is_running(N, rabbit)].
+ [N || N <- alive_nodes(), rabbit_nodes:is_process_running(N, rabbit)].
await_cluster_recovery() ->
rabbit_log:warning("Cluster minority status detected - awaiting recovery~n",
diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl
index c92e5963..5640f12a 100644
--- a/src/rabbit_nodes.erl
+++ b/src/rabbit_nodes.erl
@@ -16,7 +16,8 @@
-module(rabbit_nodes).
--export([names/1, diagnostics/1, make/1, parts/1, cookie_hash/0, is_running/2]).
+-export([names/1, diagnostics/1, make/1, parts/1, cookie_hash/0,
+ is_running/2, is_process_running/2]).
-define(EPMD_TIMEOUT, 30000).
@@ -33,6 +34,7 @@
-spec(parts/1 :: (node() | string()) -> {string(), string()}).
-spec(cookie_hash/0 :: () -> string()).
-spec(is_running/2 :: (node(), atom()) -> boolean()).
+-spec(is_process_running/2 :: (node(), atom()) -> boolean()).
-endif.
@@ -98,3 +100,10 @@ is_running(Node, Application) ->
{badrpc, _} -> false;
Apps -> proplists:is_defined(Application, Apps)
end.
+
+is_process_running(Node, Process) ->
+ case rpc:call(Node, erlang, whereis, [Process]) of
+ {badrpc, _} -> false;
+ undefined -> false;
+ P when is_pid(P) -> true
+ end.