Rename `reason` field to `stop_reason`
This commit is contained in:
parent
7454e46934
commit
41e9dad70a
|
@ -50,7 +50,7 @@
|
||||||
parse_state :: emqx_frame:parse_state(),
|
parse_state :: emqx_frame:parse_state(),
|
||||||
chan_state :: emqx_channel:channel(),
|
chan_state :: emqx_channel:channel(),
|
||||||
pendings :: list(),
|
pendings :: list(),
|
||||||
reason :: term()
|
stop_reason :: term()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(state() :: #state{}).
|
-type(state() :: #state{}).
|
||||||
|
@ -97,6 +97,12 @@ stats(#state{chan_state = ChanState}) ->
|
||||||
ChanStats = emqx_channel:stats(ChanState),
|
ChanStats = emqx_channel:stats(ChanState),
|
||||||
lists:append([ProcStats, wsock_stats(), conn_stats(), ChanStats]).
|
lists:append([ProcStats, wsock_stats(), conn_stats(), ChanStats]).
|
||||||
|
|
||||||
|
wsock_stats() ->
|
||||||
|
[{Key, emqx_pd:get_counter(Key)} || Key <- ?SOCK_STATS].
|
||||||
|
|
||||||
|
conn_stats() ->
|
||||||
|
[{Name, emqx_pd:get_counter(Name)} || Name <- ?CONN_STATS].
|
||||||
|
|
||||||
-spec(kick(pid()) -> ok).
|
-spec(kick(pid()) -> ok).
|
||||||
kick(CPid) ->
|
kick(CPid) ->
|
||||||
call(CPid, kick).
|
call(CPid, kick).
|
||||||
|
@ -312,7 +318,7 @@ websocket_info(Info, State = #state{chan_state = ChanState}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
terminate(SockError, _Req, #state{chan_state = ChanState,
|
terminate(SockError, _Req, #state{chan_state = ChanState,
|
||||||
reason = Reason}) ->
|
stop_reason = Reason}) ->
|
||||||
?LOG(debug, "Terminated for ~p, sockerror: ~p",
|
?LOG(debug, "Terminated for ~p, sockerror: ~p",
|
||||||
[Reason, SockError]),
|
[Reason, SockError]),
|
||||||
emqx_channel:terminate(Reason, ChanState).
|
emqx_channel:terminate(Reason, ChanState).
|
||||||
|
@ -424,20 +430,14 @@ reply(State = #state{chan_state = ChanState, pendings = Pendings}) ->
|
||||||
{reply, Reply, State#state{chan_state = NChanState, pendings = []}}.
|
{reply, Reply, State#state{chan_state = NChanState, pendings = []}}.
|
||||||
|
|
||||||
stop(Reason, State = #state{pendings = []}) ->
|
stop(Reason, State = #state{pendings = []}) ->
|
||||||
{stop, State#state{reason = Reason}};
|
{stop, State#state{stop_reason = Reason}};
|
||||||
stop(Reason, State = #state{pendings = Pendings}) ->
|
stop(Reason, State = #state{pendings = Pendings}) ->
|
||||||
Reply = handle_outgoing(Pendings, State),
|
Reply = handle_outgoing(Pendings, State),
|
||||||
{reply, [Reply, close],
|
{reply, [Reply, close],
|
||||||
State#state{pendings = [], reason = Reason}}.
|
State#state{pendings = [], stop_reason = Reason}}.
|
||||||
|
|
||||||
enqueue(Packet, State) when is_record(Packet, mqtt_packet) ->
|
enqueue(Packet, State) when is_record(Packet, mqtt_packet) ->
|
||||||
enqueue([Packet], State);
|
enqueue([Packet], State);
|
||||||
enqueue(Packets, State = #state{pendings = Pendings}) ->
|
enqueue(Packets, State = #state{pendings = Pendings}) ->
|
||||||
State#state{pendings = lists:append(Pendings, Packets)}.
|
State#state{pendings = lists:append(Pendings, Packets)}.
|
||||||
|
|
||||||
wsock_stats() ->
|
|
||||||
[{Key, emqx_pd:get_counter(Key)} || Key <- ?SOCK_STATS].
|
|
||||||
|
|
||||||
conn_stats() ->
|
|
||||||
[{Name, emqx_pd:get_counter(Name)} || Name <- ?CONN_STATS].
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue