Skip to content

Commit 577a07d

Browse files
author
José Valim
committed
Do not consider handler swap to be failures
1 parent f6093d4 commit 577a07d

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

lib/elixir/lib/gen_event.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,13 @@ defmodule GenEvent do
885885

886886
receive do
887887
{^ref, :ok} ->
888-
server_collect_process_handlers(:sync, event, t, [handler|handlers], name)
888+
server_collect_process_handlers(mode, event, t, [handler|handlers], name)
889889
{^ref, :done} ->
890890
do_terminate(handler, :remove_handler, event, name, :normal)
891-
server_collect_process_handlers(:sync, event, t, handlers, name)
891+
server_collect_process_handlers(mode, event, t, handlers, name)
892892
{:DOWN, ^ref, _, _, reason} ->
893893
do_terminate(handler, {:stop, reason}, :remove, name, :shutdown)
894-
server_collect_process_handlers(:sync, event, t, handlers, name)
894+
server_collect_process_handlers(mode, event, t, handlers, name)
895895
end
896896
end
897897

lib/elixir/lib/gen_event/stream.ex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,9 @@ 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} when reason in [:normal, :shutdown] ->
162+
{:gen_event_EXIT, {GenEvent.Stream, ^ref}, _reason} ->
163163
Process.demonitor(mon_ref, [:flush])
164164
:ok
165-
{:gen_event_EXIT, {GenEvent.Stream, ^ref}, reason} ->
166-
Process.demonitor(mon_ref, [:flush])
167-
{:error, reason}
168165
{:DOWN, ^mon_ref, _, _, reason} ->
169166
{:error, reason}
170167
end

lib/elixir/test/elixir/gen_event/stream_test.exs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,16 @@ defmodule GenEvent.StreamTest do
214214
stream = GenEvent.stream(pid, id: make_ref())
215215

216216
parent = self()
217-
child = spawn_link fn -> send parent, Enum.take(stream, 5) end
217+
spawn_link(fn -> send parent, Enum.take(stream, 5) end)
218218
wait_for_handlers(pid, 1)
219219

220220
for i <- 1..3 do
221221
notify(@mode, pid, i)
222222
end
223223

224224
[handler] = GenEvent.which_handlers(pid)
225-
Process.flag(:trap_exit, true)
226225
GenEvent.swap_handler(pid, handler, :swap_handler, UnknownHandler, [])
227-
assert_receive {:EXIT, ^child,
228-
{{:swapped, UnknownHandler, _},
229-
{Enumerable.GenEvent.Stream, :stop, [_, _]}}}, @receive_timeout
226+
assert_receive [1, 2, 3], @receive_timeout
230227
end
231228

232229
test "#{mode} stream/2 with manager unregistered" do

0 commit comments

Comments
 (0)