Skip to content

Commit

Permalink
inets: Create seperate timeout for TLS/SSL handshake
Browse files Browse the repository at this point in the history
We do not want this timeout to be mixed up with the keep alive timeout.
We will probably want to make it configurable later.
  • Loading branch information
IngelaAndin committed Jun 26, 2014
1 parent 54a15c0 commit 87401c3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/inets/src/http_server/httpd_request_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
-include("http_internal.hrl").
-include("httpd_internal.hrl").

-define(HANDSHAKE_TIMEOUT, 5000).
-record(state, {mod, %% #mod{}
manager, %% pid()
status, %% accept | busy | blocked
Expand Down Expand Up @@ -96,15 +97,13 @@ init([Manager, ConfigDB, AcceptTimeout]) ->

{SocketType, Socket} = await_socket_ownership_transfer(AcceptTimeout),

TimeOut = httpd_util:lookup(ConfigDB, keep_alive_timeout, 150000),
Then = erlang:now(),
KeepAliveTimeOut = httpd_util:lookup(ConfigDB, keep_alive_timeout, 150000),

case http_transport:negotiate(SocketType, Socket, TimeOut) of
case http_transport:negotiate(SocketType, Socket, ?HANDSHAKE_TIMEOUT) of
{error, _Error} ->
exit(shutdown); %% Can be 'normal'.
ok ->
NewTimeout = TimeOut - timer:now_diff(now(),Then) div 1000,
continue_init(Manager, ConfigDB, SocketType, Socket, NewTimeout)
continue_init(Manager, ConfigDB, SocketType, Socket, KeepAliveTimeOut)
end.

continue_init(Manager, ConfigDB, SocketType, Socket, TimeOut) ->
Expand Down

0 comments on commit 87401c3

Please sign in to comment.