summaryrefslogtreecommitdiff
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
commit604daf44e8f6a8da3b5900f53ca86d32c64819b5 (patch)
tree9743188ead1e13023a9efc52d817bc665f81355f
parent3ae5428b60aa7c44d207245adf47397dce6df57d (diff)
downloadrabbitmq-server-bug24728.tar.gz
use monitors instead of links to watch over net_adm:names/1 callsbug24728
thus eliminating the need to trap exits, which can interfere with the calling process, and dangling 'EXIT' messages in the mailbox.
-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 329c07dc..9a972d9e 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]),