aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2018-10-16 15:13:05 +0200
committerErlang/OTP <[email protected]>2018-10-16 15:13:05 +0200
commit55f286cdffac63ece441e948d433375e5e95989f (patch)
tree5ffdda15d1091ba327b349162340c82c16f59e34
parent0eab3e63a93235cfa0bda36d25df15fd9421e642 (diff)
parent48daac0a888f39601bb714bd4f4f78b69e224d69 (diff)
downloadotp-55f286cdffac63ece441e948d433375e5e95989f.tar.gz
otp-55f286cdffac63ece441e948d433375e5e95989f.tar.bz2
otp-55f286cdffac63ece441e948d433375e5e95989f.zip
Merge branch 'hans/eldap/prevent_EXIT_at_close/OTP-15342/ERIERL-242' into maint-20
* 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 625309271b..5b4cbe5b98 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,