mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-16 05:00:24 +00:00
Fix the flushing of messages when switching to Websocket
We now flush messages that are specific to cowboy_http only. Stream handlers should also flush their own specific messages if necessary, although timeouts will be flushed regardless of where they originate from. Also renames the http_SUITE to old_http_SUITE to distinguish new tests from old tests. Most old tests need to be removed or converted eventually as they're legacy tests from Cowboy 1.0.
This commit is contained in:
parent
4d5174632c
commit
5964273cc4
24 changed files with 883 additions and 777 deletions
|
@ -1004,7 +1004,7 @@ commands(State0=#state{ref=Ref, parent=Parent, socket=Socket, transport=Transpor
|
|||
stream_call_terminate(StreamID, switch_protocol, StreamState),
|
||||
%% Terminate children processes and flush any remaining messages from the mailbox.
|
||||
cowboy_children:terminate(Children),
|
||||
flush(),
|
||||
flush(Parent),
|
||||
%% @todo This is no good because commands return a state normally and here it doesn't
|
||||
%% we need to let this module go entirely. Perhaps it should be handled directly in
|
||||
%% cowboy_clear/cowboy_tls?
|
||||
|
@ -1030,8 +1030,19 @@ headers_to_list(Headers0=#{<<"set-cookie">> := SetCookies}) ->
|
|||
headers_to_list(Headers) ->
|
||||
maps:to_list(Headers).
|
||||
|
||||
flush() ->
|
||||
receive _ -> flush() after 0 -> ok end.
|
||||
%% Flush messages specific to cowboy_http before handing over the
|
||||
%% connection to another protocol.
|
||||
flush(Parent) ->
|
||||
receive
|
||||
{timeout, _, _} ->
|
||||
flush(Parent);
|
||||
{{Pid, _}, _} when Pid =:= self() ->
|
||||
flush(Parent);
|
||||
{'EXIT', Pid, _} when Pid =/= Parent ->
|
||||
flush(Parent)
|
||||
after 0 ->
|
||||
ok
|
||||
end.
|
||||
|
||||
%% @todo In these cases I'm not sure if we should continue processing commands.
|
||||
maybe_terminate(State=#state{last_streamid=StreamID}, StreamID, _Tail) ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue