aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2018-10-12 17:12:05 +0200
committerErlang/OTP <[email protected]>2018-10-12 17:12:05 +0200
commit09d544e70dd30b2ac0ba920aaa87784f7b412a76 (patch)
tree4189dfc25ab0f218947ca1786b10873ab7a5652a
parent773d665794a6cfd6a95ef024666980fb68ab9dac (diff)
parent48daac0a888f39601bb714bd4f4f78b69e224d69 (diff)
downloadotp-09d544e70dd30b2ac0ba920aaa87784f7b412a76.tar.gz
otp-09d544e70dd30b2ac0ba920aaa87784f7b412a76.tar.bz2
otp-09d544e70dd30b2ac0ba920aaa87784f7b412a76.zip
Merge branch 'hans/eldap/prevent_EXIT_at_close/OTP-15342/ERIERL-242' into maint-21
* hans/eldap/prevent_EXIT_at_close/OTP-15342/ERIERL-242: eldap: Fix race at socket close
-rw-r--r--lib/eldap/src/eldap.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/eldap/src/eldap.erl b/lib/eldap/src/eldap.erl
index 2b84872b92..6497922852 100644
--- a/lib/eldap/src/eldap.erl
+++ b/lib/eldap/src/eldap.erl
@@ -957,10 +957,19 @@ do_modify_dn_0(Data, Entry, NewRDN, DelOldRDN, NewSup, Controls) ->
do_unbind(Data) ->
Req = "",
log2(Data, "unbind request = ~p (has no reply)~n", [Req]),
- send_request(Data#eldap.fd, Data, Data#eldap.id, {unbindRequest, Req}),
case Data#eldap.using_tls of
- true -> ssl:close(Data#eldap.fd);
- false -> gen_tcp:close(Data#eldap.fd)
+ true ->
+ send_request(Data#eldap.fd, Data, Data#eldap.id, {unbindRequest, Req}),
+ ssl:close(Data#eldap.fd);
+ false ->
+ OldTrapExit = process_flag(trap_exit, true),
+ catch send_request(Data#eldap.fd, Data, Data#eldap.id, {unbindRequest, Req}),
+ catch gen_tcp:close(Data#eldap.fd),
+ receive
+ {'EXIT', _From, _Reason} -> ok
+ after 0 -> ok
+ end,
+ process_flag(trap_exit, OldTrapExit)
end,
{no_reply, Data#eldap{binddn = (#eldap{})#eldap.binddn,
passwd = (#eldap{})#eldap.passwd,