From e8d0a8654ecf85f89a0c0f7aa26da8bc467e9373 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Fri, 2 Mar 2018 16:51:11 +0100 Subject: stdlib: Remove obsolete use of monitor_node as fallback when erlang:monitor failed toward primitive nodes, which it does not do in OTP-21. --- lib/stdlib/src/gen.erl | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'lib/stdlib/src/gen.erl') diff --git a/lib/stdlib/src/gen.erl b/lib/stdlib/src/gen.erl index 0e6f49d99f..dc957b4d4e 100644 --- a/lib/stdlib/src/gen.erl +++ b/lib/stdlib/src/gen.erl @@ -158,8 +158,7 @@ call(Process, Label, Request, Timeout) do_for_proc(Process, Fun). do_call(Process, Label, Request, Timeout) -> - try erlang:monitor(process, Process) of - Mref -> + Mref = erlang:monitor(process, Process), %% If the monitor/2 call failed to set up a connection to a %% remote node, we don't want the '!' operator to attempt %% to set up the connection again. (If the monitor/2 call @@ -183,27 +182,7 @@ do_call(Process, Label, Request, Timeout) -> after Timeout -> erlang:demonitor(Mref, [flush]), exit(timeout) - end - catch - error:_ -> - %% Node (C/Java?) is not supporting the monitor. - %% The other possible case -- this node is not distributed - %% -- should have been handled earlier. - %% Do the best possible with monitor_node/2. - %% This code may hang indefinitely if the Process - %% does not exist. It is only used for featureweak remote nodes. - Node = get_node(Process), - monitor_node(Node, true), - receive - {nodedown, Node} -> - monitor_node(Node, false), - exit({nodedown, Node}) - after 0 -> - Tag = make_ref(), - Process ! {Label, {self(), Tag}, Request}, - wait_resp(Node, Tag, Timeout) - end - end. + end. get_node(Process) -> %% We trust the arguments to be correct, i.e @@ -217,19 +196,6 @@ get_node(Process) -> node(Process) end. -wait_resp(Node, Tag, Timeout) -> - receive - {Tag, Reply} -> - monitor_node(Node, false), - {ok, Reply}; - {nodedown, Node} -> - monitor_node(Node, false), - exit({nodedown, Node}) - after Timeout -> - monitor_node(Node, false), - exit(timeout) - end. - %% %% Send a reply to the client. %% -- cgit v1.2.3