From 6fdcba641e40c25778e83740a1055f28b6ef5149 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Wed, 14 Dec 2022 10:39:58 -0300 Subject: [PATCH] test(refactor): no need for monitor the janitor is already linked to the parent --- apps/emqx/test/emqx_test_janitor.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/emqx/test/emqx_test_janitor.erl b/apps/emqx/test/emqx_test_janitor.erl index b7d2c3507..6e81fa81d 100644 --- a/apps/emqx/test/emqx_test_janitor.erl +++ b/apps/emqx/test/emqx_test_janitor.erl @@ -49,8 +49,7 @@ push_on_exit_callback(Server, Callback) when is_function(Callback, 0) -> init(Parent) -> process_flag(trap_exit, true), - Ref = monitor(process, Parent), - {ok, #{callbacks => [], owner => {Ref, Parent}}}. + {ok, #{callbacks => [], owner => Parent}}. terminate(_Reason, #{callbacks := Callbacks}) -> lists:foreach(fun(Fun) -> Fun() end, Callbacks). @@ -63,7 +62,7 @@ handle_call(_Req, _From, State) -> handle_cast(_Req, State) -> {noreply, State}. -handle_info({'DOWN', Ref, process, Parent, _Reason}, State = #{owner := {Ref, Parent}}) -> +handle_info({'EXIT', Parent, _Reason}, State = #{owner := Parent}) -> {stop, normal, State}; handle_info(_Msg, State) -> {noreply, State}.