diff options
author | Erlang/OTP <[email protected]> | 2018-10-18 17:42:23 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2018-10-18 17:42:23 +0200 |
commit | d6b55f9bf3c041436685578ff3101a44c6921076 (patch) | |
tree | 449b7c77a8e5f036031a49c5b5889a90a6467f3d /lib | |
parent | 58966e6d0b8ebdb96db02e42dd422f15be829df1 (diff) | |
parent | 48daac0a888f39601bb714bd4f4f78b69e224d69 (diff) | |
download | otp-d6b55f9bf3c041436685578ff3101a44c6921076.tar.gz otp-d6b55f9bf3c041436685578ff3101a44c6921076.tar.bz2 otp-d6b55f9bf3c041436685578ff3101a44c6921076.zip |
Merge branch 'hans/eldap/prevent_EXIT_at_close/OTP-15342/ERIERL-242' into maint-19
* hans/eldap/prevent_EXIT_at_close/OTP-15342/ERIERL-242:
eldap: Fix race at socket close
Diffstat (limited to 'lib')
-rw-r--r-- | lib/eldap/src/eldap.erl | 15 |
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, |