Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit fb05f52

Browse files
Use a function call effect
so that this state transition applied on the leader node only.
1 parent ac65099 commit fb05f52

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/mqtt_machine.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ apply(Meta, {register, ClientId, Pid}, #state{client_ids = Ids} = State0) ->
4545
{Effects, Ids1} =
4646
case maps:find(ClientId, Ids) of
4747
{ok, OldPid} when Pid =/= OldPid ->
48-
catch gen_server2:cast(OldPid, duplicate_id),
49-
{[{demonitor, process, OldPid},
50-
{monitor, process, Pid}], maps:remove(ClientId, Ids)};
48+
Effects0 = [{demonitor, process, OldPid},
49+
{monitor, process, Pid},
50+
{mod_call, gen_server2, cast, [OldPid, duplicate_id]}],
51+
{Effects0, maps:remove(ClientId, Ids)};
5152
error ->
52-
{[{monitor, process, Pid}], Ids}
53+
Effects0 = [{monitor, process, Pid}],
54+
{Effects0, Ids}
5355
end,
5456
State = State0#state{client_ids = maps:put(ClientId, Pid, Ids1)},
5557
{State, ok, Effects ++ snapshot_effects(Meta, State)};

0 commit comments

Comments
 (0)