Skip to content

Commit 7863d5f

Browse files
committed
change order of execution in gproc_monitor
1 parent e4cbf2a commit 7863d5f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/gproc_monitor.erl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,24 @@ handle_cast({unsubscribe, Pid, Key}, State) ->
177177
%%--------------------------------------------------------------------
178178
handle_info({gproc, unreg, _Ref, Name}, State) ->
179179
ets:delete(?TAB, {m, Name}),
180-
notify(Name, undefined),
181180
do_monitor(Name, undefined),
181+
notify(Name, undefined),
182182
{noreply, State};
183183
handle_info({gproc, {migrated,ToPid}, _Ref, Name}, State) ->
184184
ets:delete(?TAB, {m, Name}),
185+
do_monitor(Name, ToPid),
185186
notify(Name, {migrated, ToPid}),
187+
{noreply, State};
188+
handle_info({gproc, {failover,ToPid}, _Ref, Name}, State) ->
189+
ets:delete(?TAB, {m, Name}),
186190
do_monitor(Name, ToPid),
191+
notify(Name, {failover, ToPid}),
187192
{noreply, State};
188193
handle_info({gproc, _, registered, {{T,_,_} = Name, Pid, _}}, State)
189194
when T==n; T==a ->
190195
ets:delete(?TAB, {w, Name}),
191-
notify(Name, Pid),
192196
do_monitor(Name, Pid),
197+
notify(Name, Pid),
193198
{noreply, State};
194199
handle_info({'DOWN', _, process, Pid, _}, State) ->
195200
pid_is_down(Pid),
@@ -239,7 +244,9 @@ do_monitor(Name, undefined) ->
239244
case ets:member(?TAB, {w, Name}) of
240245
false ->
241246
Ref = gproc:nb_wait(Name),
242-
ets:insert(?TAB, {{w, Name}, Ref})
247+
ets:insert(?TAB, {{w, Name}, Ref});
248+
true ->
249+
ok
243250
end;
244251
do_monitor(Name, Pid) when is_pid(Pid) ->
245252
case ets:member(?TAB, {m, Name}) of

0 commit comments

Comments
 (0)