aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-09-26 13:41:09 +0200
committerLoïc Hoguin <[email protected]>2019-09-26 13:41:09 +0200
commit568872e546660444919ed5e6497b5da1410baa77 (patch)
treed1b8f6200cc41a237468102f2624fa5f60c223ed
parentddc87f339f441fe5b62455606cf6ed6fb8dbc461 (diff)
downloadgun-568872e546660444919ed5e6497b5da1410baa77.tar.gz
gun-568872e546660444919ed5e6497b5da1410baa77.tar.bz2
gun-568872e546660444919ed5e6497b5da1410baa77.zip
Don't send duplicate gun_error messages to the same process
-rw-r--r--src/gun_http2.erl9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl
index 6a443e3..1cfbd4a 100644
--- a/src/gun_http2.erl
+++ b/src/gun_http2.erl
@@ -730,13 +730,8 @@ down(#http2_state{streams=Streams}) ->
connection_error(#http2_state{socket=Socket, transport=Transport,
http2_machine=HTTP2Machine, streams=Streams},
{connection_error, Reason, _}) ->
- %% The connection is going away either at the request of the server,
- %% or because an error occurred in the protocol. Inform the streams.
- %% @todo We should not send duplicate messages to processes.
- %% @todo We should probably also inform the owner process.
-
- %% @todo Somehow streams aren't removed on receiving a response.
- _ = [ReplyTo ! {gun_error, self(), Reason} || #stream{reply_to=ReplyTo} <- Streams],
+ Pids = lists:usort([ReplyTo || #stream{reply_to=ReplyTo} <- Streams]),
+ _ = [Pid ! {gun_error, self(), Reason} || Pid <- Pids],
Transport:send(Socket, cow_http2:goaway(
cow_http2_machine:get_last_streamid(HTTP2Machine),
Reason, <<>>)),