aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-04-24 15:56:01 +0200
committerLoïc Hoguin <[email protected]>2019-04-24 16:38:53 +0200
commitf48336d4a5df7789613a64e3d267b39ddbe92d85 (patch)
treef57f62a86659971432a32e690c97f142d01942b7
parentbeac669a066f3d8936c392976531a0070ce93c63 (diff)
downloadgun-f48336d4a5df7789613a64e3d267b39ddbe92d85.tar.gz
gun-f48336d4a5df7789613a64e3d267b39ddbe92d85.tar.bz2
gun-f48336d4a5df7789613a64e3d267b39ddbe92d85.zip
Prevent ssl:setopts from blocking gun_tls_proxy
-rw-r--r--src/gun_tls_proxy.erl5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gun_tls_proxy.erl b/src/gun_tls_proxy.erl
index d66e91c..bd3e7fa 100644
--- a/src/gun_tls_proxy.erl
+++ b/src/gun_tls_proxy.erl
@@ -233,7 +233,10 @@ not_connected(cast, Msg={connect_proc, {ok, Socket}}, State=#state{owner_pid=Own
_ -> gun_http
end,
OwnerPid ! {connect_protocol, Protocol},
- ok = ssl:setopts(Socket, [{active, true}]),
+ %% We need to spawn this call before OTP-21.2 because it triggers
+ %% a cb_setopts call that blocks us. Might be OK to just leave it
+ %% like this once we support 21.2+ only.
+ spawn(fun() -> ok = ssl:setopts(Socket, [{active, true}]) end),
{next_state, connected, State#state{proxy_socket=Socket}};
not_connected(cast, Msg={connect_proc, Error}, State) ->
?DEBUG_LOG("msg ~0p state ~0p", [Msg, State]),