Fix issue #1340 - erlang:demonitor/1 the reference when erasing the monitor

This commit is contained in:
Feng Lee 2017-11-20 10:10:32 +08:00
parent d794273bdb
commit 14771cdaee
2 changed files with 2 additions and 0 deletions

View File

@ -152,6 +152,7 @@ monitor_client(ClientId, Pid, State = #state{monitors = Monitors}) ->
State#state{monitors = dict:store(MRef, {ClientId, Pid}, Monitors)}.
erase_monitor(MRef, State = #state{monitors = Monitors}) ->
erlang:demonitor(MRef, [flush]),
State#state{monitors = dict:erase(MRef, Monitors)}.
setstats(State = #state{statsfun = StatsFun}) ->

View File

@ -310,5 +310,6 @@ monitor_session(ClientId, SessPid, State = #state{monitors = Monitors}) ->
State#state{monitors = dict:store(MRef, ClientId, Monitors)}.
erase_monitor(MRef, State = #state{monitors = Monitors}) ->
erlang:demonitor(MRef, [flush]),
State#state{monitors = dict:erase(MRef, Monitors)}.