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

Fix shutdown for HTTP/1.1 pipeline

Sending extra response prevented by terminating all streams except
the one currently executing.

LH: Reworded some variables to make what happens more obvious.
This commit is contained in:
Dmitri Vereshchagin 2022-10-06 00:24:43 +03:00 committed by Loïc Hoguin
parent 03a3bf4474
commit 2558ba65ad
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
4 changed files with 36 additions and 27 deletions

View file

@ -1472,10 +1472,12 @@ early_error(StatusCode0, State=#state{socket=Socket, transport=Transport,
initiate_closing(State=#state{streams=[]}, Reason) ->
terminate(State, Reason);
initiate_closing(State=#state{streams=[_Stream|Streams],
initiate_closing(State=#state{streams=Streams,
out_streamid=OutStreamID}, Reason) ->
terminate_all_streams(State, Streams, Reason),
State#state{last_streamid=OutStreamID}.
{value, LastStream, TerminatedStreams}
= lists:keytake(OutStreamID, #stream.id, Streams),
terminate_all_streams(State, TerminatedStreams, Reason),
State#state{streams=[LastStream], last_streamid=OutStreamID}.
%% Function replicated in cowboy_http2.
maybe_socket_error(State, {error, closed}) ->