From 5a1b9a836675b025eb1611f23ee9e2f5e4efa156 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 5 Mar 2018 15:47:59 +0100 Subject: stdlib: Fix receive-ref optimization for gen_server:call Optimization does not trigger for try-catch. But send cannot fail here anyway, as Process cannot be an atom. --- lib/stdlib/src/gen.erl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/gen.erl b/lib/stdlib/src/gen.erl index 293cb98ad2..2e6223d2bb 100644 --- a/lib/stdlib/src/gen.erl +++ b/lib/stdlib/src/gen.erl @@ -157,15 +157,14 @@ call(Process, Label, Request, Timeout) Fun = fun(Pid) -> do_call(Pid, Label, Request, Timeout) end, do_for_proc(Process, Fun). -do_call(Process, Label, Request, Timeout) -> +do_call(Process, Label, Request, Timeout) when is_atom(Process) =:= false -> Mref = erlang:monitor(process, Process), + %% OTP-21: %% Auto-connect is asynchronous. But we still use 'noconnect' to make sure %% we send on the monitored connection, and not trigger a new auto-connect. - try erlang:send(Process, {Label, {self(), Mref}, Request}, [noconnect]) - catch - error:_ -> ok - end, + %% + erlang:send(Process, {Label, {self(), Mref}, Request}, [noconnect]), receive {Mref, Reply} -> -- cgit v1.2.3