diff options
| author | Matthias Radestock <matthias@rabbitmq.com> | 2012-03-20 23:44:05 +0000 |
|---|---|---|
| committer | Matthias Radestock <matthias@rabbitmq.com> | 2012-03-20 23:44:05 +0000 |
| commit | b617e4f997c76982e646e929edbc5c5fb3dbacc8 (patch) | |
| tree | 9743188ead1e13023a9efc52d817bc665f81355f | |
| parent | 5f424ad41584ac491c8ce84db404e5a5f21635e1 (diff) | |
| download | rabbitmq-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.
| -rw-r--r-- | src/rabbit_nodes.erl | 16 |
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]), |
