0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

Fix terminate not being called on connection close in HTTP/1.1

Introduces the new stream_handler_SUITE test suite. More cases
will be added later on.
This commit is contained in:
Loïc Hoguin 2017-06-02 12:31:00 +02:00
parent cbf7972f10
commit 767da623f1
No known key found for this signature in database
GPG key ID: 71366FF21851DF03
3 changed files with 122 additions and 1 deletions

View file

@ -1069,11 +1069,20 @@ error_terminate(StatusCode0, State=#state{ref=Ref, socket=Socket, transport=Tran
terminate(State, Reason).
-spec terminate(_, _) -> no_return().
terminate(#state{children=Children}, _Reason) ->
terminate(undefined, Reason) ->
exit({shutdown, Reason});
terminate(#state{streams=Streams, children=Children}, Reason) ->
terminate_all_streams(Streams, Reason),
%% @todo Leave them time to terminate.
_ = [exit(Pid, kill) || {Pid, _, _} <- Children],
exit(normal). %% @todo We probably don't want to exit normal on errors.
terminate_all_streams([], _) ->
ok;
terminate_all_streams([#stream{id=StreamID, state=StreamState}|Tail], Reason) ->
stream_call_terminate(StreamID, Reason, StreamState),
terminate_all_streams(Tail, Reason).
%% System callbacks.
-spec system_continue(_, _, {#state{}, binary()}) -> ok.