aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/net_kernel.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-12-17 10:59:50 +0100
committerLukas Larsson <[email protected]>2019-02-21 16:37:59 +0100
commit45c57256d06b14bae7a4f19978a375e360b609cf (patch)
treec6b7ea9b6519038bb7002dba02a7cb377b45575b /lib/kernel/src/net_kernel.erl
parent5c8f2bee9a427768c187a35a6ecd720faa860200 (diff)
downloadotp-45c57256d06b14bae7a4f19978a375e360b609cf.tar.gz
otp-45c57256d06b14bae7a4f19978a375e360b609cf.tar.bz2
otp-45c57256d06b14bae7a4f19978a375e360b609cf.zip
erts: Yield later during process exit and allow free procs to run
OTP-15610
Diffstat (limited to 'lib/kernel/src/net_kernel.erl')
-rw-r--r--lib/kernel/src/net_kernel.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl
index 4915193196..83d3b4b5e1 100644
--- a/lib/kernel/src/net_kernel.erl
+++ b/lib/kernel/src/net_kernel.erl
@@ -1126,14 +1126,22 @@ do_disconnect(Node, State) ->
{false, State}
end.
-
disconnect_pid(Pid, State) ->
exit(Pid, disconnect),
+
+ %% This code used to only use exit + recv 'EXIT' to sync,
+ %% but since OTP-22 links are no longer broken atomically
+ %% so the exit message below can arrive before any remaining
+ %% exit messages have killed the distribution port
+ Ref = erlang:monitor(process, Pid),
%% Sync wait for connection to die!!!
receive
- {'EXIT',Pid,Reason} ->
- {_,State1} = handle_exit(Pid, Reason, State),
- {true, State1}
+ {'DOWN',Ref,_,_,_} ->
+ receive
+ {'EXIT',Pid,Reason} ->
+ {_,State1} = handle_exit(Pid, Reason, State),
+ {true, State1}
+ end
end.
%%