summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-11-01 11:33:58 +0000
committerSimon MacMullen <simon@rabbitmq.com>2011-11-01 11:33:58 +0000
commit74ccc33f89f401081c908432a9d80a383a204d23 (patch)
treeb33140410ecc4cfcf2bda1f279a9aa0747ca067c
parent9d851e0ab750cc154cb418fff6e6efa4241ee00e (diff)
parent8e1cf664ccf6235f9bb6deb161739d3054ebe6ef (diff)
downloadrabbitmq-server-74ccc33f89f401081c908432a9d80a383a204d23.tar.gz
Merge bug24525
-rw-r--r--src/rabbit_prelaunch.erl16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/rabbit_prelaunch.erl b/src/rabbit_prelaunch.erl
index 8beff019..50444dc4 100644
--- a/src/rabbit_prelaunch.erl
+++ b/src/rabbit_prelaunch.erl
@@ -22,6 +22,7 @@
-define(BaseApps, [rabbit]).
-define(ERROR_CODE, 1).
+-define(EPMD_TIMEOUT, 30000).
%%----------------------------------------------------------------------------
%% Specs
@@ -245,7 +246,7 @@ duplicate_node_check([]) ->
duplicate_node_check(NodeStr) ->
Node = rabbit_misc:makenode(NodeStr),
{NodeName, NodeHost} = rabbit_misc:nodeparts(Node),
- case net_adm:names(NodeHost) of
+ case names(NodeHost) of
{ok, NamePorts} ->
case proplists:is_defined(NodeName, NamePorts) of
true -> io:format("node with name ~p "
@@ -261,6 +262,7 @@ duplicate_node_check(NodeStr) ->
[NodeHost, EpmdReason,
case EpmdReason of
address -> "unable to establish tcp connection";
+ timeout -> "timed out establishing tcp connection";
_ -> inet:format_error(EpmdReason)
end])
end.
@@ -277,3 +279,15 @@ terminate(Status) ->
after infinity -> ok
end
end.
+
+names(Hostname) ->
+ Self = self(),
+ process_flag(trap_exit, true),
+ Pid = spawn_link(fun () -> Self ! {names, net_adm:names(Hostname)} end),
+ timer:exit_after(?EPMD_TIMEOUT, Pid, timeout),
+ Res = receive
+ {names, Names} -> Names;
+ {'EXIT', Pid, Reason} -> {error, Reason}
+ end,
+ process_flag(trap_exit, false),
+ Res.