fix(stomp): fix kick/discard crash errors

This commit is contained in:
JianBo He 2021-11-02 12:27:15 +08:00
parent ed505ee120
commit d2924e82ab
1 changed files with 6 additions and 2 deletions

View File

@ -229,10 +229,11 @@ handle_call(info, _From, State = #state{transport = Transport,
end;
handle_call(discard, _From, State) ->
shutdown(discared, State);
%% TODO: send the DISCONNECT packet?
shutdown_and_reply(discared, ok, State);
handle_call(kick, _From, State) ->
shutdown(kicked, State);
shutdown_and_reply(kicked, ok, State);
handle_call(Req, _From, State) ->
?LOG(error, "unexpected request: ~p", [Req]),
@ -491,6 +492,9 @@ stop(Reason, State) ->
shutdown(Reason, State) ->
stop({shutdown, Reason}, State).
shutdown_and_reply(Reason, Reply, State) ->
{stop, {shutdown, Reason}, Reply, State}.
inc_counter(Key, Inc) ->
_ = emqx_pd:inc_counter(Key, Inc),
ok.