aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src/prim_inet.erl
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2013-11-28 15:04:32 +0100
committerRickard Green <[email protected]>2013-11-28 15:04:32 +0100
commit9f998969014095333545cb118467e1ff8d450c31 (patch)
treecfb7462c2a39db73f4f2c3319dc133e16b28d028 /erts/preloaded/src/prim_inet.erl
parent0519e57f544a2dc1f60e5524d000f2211fc029e8 (diff)
parente16f564fe0d64017d5cfcf56255f0a6965a6a471 (diff)
downloadotp-9f998969014095333545cb118467e1ff8d450c31.tar.gz
otp-9f998969014095333545cb118467e1ff8d450c31.tar.bz2
otp-9f998969014095333545cb118467e1ff8d450c31.zip
Merge branch 'rickard/prim_inet_close/OTP-11491' into maint
* rickard/prim_inet_close/OTP-11491: Fix prim_inet:close/1
Diffstat (limited to 'erts/preloaded/src/prim_inet.erl')
-rw-r--r--erts/preloaded/src/prim_inet.erl28
1 files changed, 2 insertions, 26 deletions
diff --git a/erts/preloaded/src/prim_inet.erl b/erts/preloaded/src/prim_inet.erl
index aa700c5194..a9df75327c 100644
--- a/erts/preloaded/src/prim_inet.erl
+++ b/erts/preloaded/src/prim_inet.erl
@@ -186,32 +186,8 @@ close_pend_loop(S, N) ->
end.
close_port(S) ->
- case erlang:process_info(self(), trap_exit) of
- {trap_exit,true} ->
- %% Ensure exit message and consume it
- link(S),
- %% This is still not a perfect solution.
- %%
- %% The problem is to close the port and consume any exit
- %% message while not knowing if this process traps exit
- %% nor if this process has a link to the port. Here we
- %% just knows that this process traps exit.
- %%
- %% If we right here get killed for some reason that exit
- %% signal will propagate to the port and onwards to anyone
- %% that is linked to the port. E.g when we close a socket
- %% that is not ours.
- %%
- %% The problem can be solved with lists:member on our link
- %% list but we deem that as potentially too expensive. We
- %% need an is_linked/1 function or guard, or we need
- %% a port_close function that can atomically unlink...
- catch erlang:port_close(S),
- receive {'EXIT',S,_} -> ok end;
- {trap_exit,false} ->
- catch erlang:port_close(S),
- ok
- end.
+ catch erlang:port_close(S),
+ receive {'EXIT',S,_} -> ok after 0 -> ok end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%