diff options
author | Hans Nilsson <[email protected]> | 2018-10-01 15:24:49 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2018-10-05 09:26:51 +0200 |
commit | 48daac0a888f39601bb714bd4f4f78b69e224d69 (patch) | |
tree | 6b0176b070f4d8444bfa7ac620e8cf6684076df0 /lib/eldap/src/eldap.erl | |
parent | 3b7a6ffddc819bf305353a593904cea9e932e7dc (diff) | |
download | otp-48daac0a888f39601bb714bd4f4f78b69e224d69.tar.gz otp-48daac0a888f39601bb714bd4f4f78b69e224d69.tar.bz2 otp-48daac0a888f39601bb714bd4f4f78b69e224d69.zip |
eldap: Fix race at socket close
Diffstat (limited to 'lib/eldap/src/eldap.erl')
-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, |