summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-03-20 23:44:05 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2012-03-20 23:44:05 +0000
commitb617e4f997c76982e646e929edbc5c5fb3dbacc8 (patch)
tree9743188ead1e13023a9efc52d817bc665f81355f /src
parent5f424ad41584ac491c8ce84db404e5a5f21635e1 (diff)
downloadrabbitmq-server-git-b617e4f997c76982e646e929edbc5c5fb3dbacc8.tar.gz
use monitors instead of links to watch over net_adm:names/1 calls
thus eliminating the need to trap exits, which can interfere with the calling process, and dangling 'EXIT' messages in the mailbox.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_nodes.erl16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl
index 329c07dc9f..9a972d9e78 100644
--- a/src/rabbit_nodes.erl
+++ b/src/rabbit_nodes.erl
@@ -39,15 +39,15 @@
names(Hostname) ->
Self = self(),
- process_flag(trap_exit, true),
- Pid = spawn_link(fun () -> Self ! {names, net_adm:names(Hostname)} end),
+ Ref = make_ref(),
+ {Pid, MRef} = spawn_monitor(
+ fun () -> Self ! {Ref, 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.
+ receive
+ {Ref, Names} -> erlang:demonitor(MRef, [flush]),
+ Names;
+ {'DOWN', MRef, process, Pid, Reason} -> {error, Reason}
+ end.
diagnostics(Nodes) ->
Hosts = lists:usort([element(2, parts(Node)) || Node <- Nodes]),