Skip to content

Commit

Permalink
elli_tcp: cast 'accepted' AFTER TLS handshake succeeded
Browse files Browse the repository at this point in the history
fix #84
  • Loading branch information
sg2342 authored and Stefan Grundmann committed Sep 26, 2020
1 parent 968afee commit c919553
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/elli_tcp.erl
Expand Up @@ -37,26 +37,27 @@ accept({plain, Socket}, Server, Timeout) ->
accept({ssl, Socket}, Server, Timeout) ->
case ssl:transport_accept(Socket, Timeout) of
{ok, S} ->
gen_server:cast(Server, accepted),
handshake(S, Timeout);
handshake(S, Server, Timeout);
{error, Reason} ->
{error, Reason}
end.

-ifdef(post20).
handshake(S, Timeout) ->
handshake(S, Server, Timeout) ->
case ssl:handshake(S, Timeout) of
{ok, S1} ->
gen_server:cast(Server, accepted),
{ok, {ssl, S1}};
{error, closed} ->
{error, econnaborted};
{error, Reason} ->
{error, Reason}
end.
-else.
handshake(S, Timeout) ->
handshake(S, Server, Timeout) ->
case ssl:ssl_accept(S, Timeout) of
ok ->
gen_server:cast(Server, accepted),
{ok, {ssl, S}};
{error, closed} ->
{error, econnaborted};
Expand Down

0 comments on commit c919553

Please sign in to comment.