Skip to content

Commit d521d79

Browse files
author
José Valim
committed
Leave clause in case the handler can fail
1 parent 7313d26 commit d521d79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/elixir/lib/gen_event/stream.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,15 @@ defimpl Enumerable, for: GenEvent.Stream do
159159
{_from, {^pid, ^ref}, {notify, _event}} when notify in [:ack_notify, :sync_notify] ->
160160
send pid, {ref, :done}
161161
wait_for_handler_removal(pid, ref, mon_ref)
162-
{:gen_event_EXIT, {GenEvent.Stream, ^ref}, _reason} ->
162+
{:gen_event_EXIT, {GenEvent.Stream, ^ref}, reason}
163+
when reason == :normal
164+
when reason == :shutdown
165+
when tuple_size(reason) == 3 and elem(reason, 0) == :swapped ->
163166
Process.demonitor(mon_ref, [:flush])
164167
:ok
168+
{:gen_event_EXIT, {GenEvent.Stream, ^ref}, reason} ->
169+
Process.demonitor(mon_ref, [:flush])
170+
{:error, reason}
165171
{:DOWN, ^mon_ref, _, _, reason} ->
166172
{:error, reason}
167173
end

0 commit comments

Comments
 (0)