diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2013-03-22 14:40:47 +0000 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2013-03-22 14:40:47 +0000 |
commit | 24667bfce161c25bfca584e85d3ebec65156930e (patch) | |
tree | 4ac78a986f298c7f584ddd4ab521c551dc60d9b1 | |
parent | ab88adcf3163b7b4ebd93306eb900490be433516 (diff) | |
download | rabbitmq-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.erl | 2 | ||||
-rw-r--r-- | src/rabbit_nodes.erl | 11 |
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. |