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 | 604daf44e8f6a8da3b5900f53ca86d32c64819b5 (patch) | |
tree | 9743188ead1e13023a9efc52d817bc665f81355f | |
parent | 3ae5428b60aa7c44d207245adf47397dce6df57d (diff) | |
download | rabbitmq-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.erl | 16 |
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]), |