From 568872e546660444919ed5e6497b5da1410baa77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 26 Sep 2019 13:41:09 +0200 Subject: Don't send duplicate gun_error messages to the same process --- src/gun_http2.erl | 9 ++------- 1 file 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, <<>>)), -- cgit v1.2.3