Remove the 'stop_reason' field

This commit is contained in:
Feng Lee 2019-12-16 12:45:46 +08:00
parent 635c3f75fe
commit 1f25f4439f
2 changed files with 13 additions and 14 deletions

View File

@ -88,10 +88,10 @@
gc_state :: maybe(emqx_gc:gc_state()), gc_state :: maybe(emqx_gc:gc_state()),
%% Stats Timer %% Stats Timer
stats_timer :: disabled | maybe(reference()), stats_timer :: disabled | maybe(reference()),
%% Idle Timer
idle_timer :: maybe(reference()),
%% Idle Timeout %% Idle Timeout
idle_timeout :: integer() idle_timeout :: integer(),
%% Idle Timer
idle_timer :: maybe(reference())
}). }).
-type(state() :: #state{}). -type(state() :: #state{}).
@ -208,8 +208,8 @@ init_state(Transport, Socket, Options) ->
channel = Channel, channel = Channel,
gc_state = GcState, gc_state = GcState,
stats_timer = StatsTimer, stats_timer = StatsTimer,
idle_timer = IdleTimer, idle_timeout = IdleTimeout,
idle_timeout = IdleTimeout idle_timer = IdleTimer
}. }.
run_loop(Parent, State = #state{transport = Transport, run_loop(Parent, State = #state{transport = Transport,

View File

@ -81,9 +81,7 @@
%% Idle Timeout %% Idle Timeout
idle_timeout :: timeout(), idle_timeout :: timeout(),
%% Idle Timer %% Idle Timer
idle_timer :: reference(), idle_timer :: reference()
%% The Stop Reason
stop_reason :: term()
}). }).
-type(state() :: #state{}). -type(state() :: #state{}).
@ -131,8 +129,10 @@ info(postponed, #state{postponed = Postponed}) ->
Postponed; Postponed;
info(stats_timer, #state{stats_timer = TRef}) -> info(stats_timer, #state{stats_timer = TRef}) ->
TRef; TRef;
info(stop_reason, #state{stop_reason = Reason}) -> info(idle_timeout, #state{idle_timeout = Timeout}) ->
Reason. Timeout;
info(idle_timer, #state{idle_timer = TRef}) ->
TRef.
-spec(stats(pid()|state()) -> emqx_types:stats()). -spec(stats(pid()|state()) -> emqx_types:stats()).
stats(WsPid) when is_pid(WsPid) -> stats(WsPid) when is_pid(WsPid) ->
@ -318,8 +318,8 @@ websocket_close(Reason, State) ->
?LOG(debug, "Websocket closed due to ~p~n", [Reason]), ?LOG(debug, "Websocket closed due to ~p~n", [Reason]),
handle_info({sock_closed, Reason}, State). handle_info({sock_closed, Reason}, State).
terminate(Error, _Req, #state{channel = Channel, stop_reason = Reason}) -> terminate(Reason, _Req, #state{channel = Channel}) ->
?LOG(debug, "Terminated for ~p, error: ~p", [Reason, Error]), ?LOG(debug, "Terminated due to ~p", [Reason]),
emqx_channel:terminate(Reason, Channel). emqx_channel:terminate(Reason, Channel).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -610,8 +610,7 @@ enqueue(Other, State = #state{postponed = Postponed}) ->
State#state{postponed = [Other|Postponed]}. State#state{postponed = [Other|Postponed]}.
shutdown(Reason, State = #state{postponed = Postponed}) -> shutdown(Reason, State = #state{postponed = Postponed}) ->
Postponed1 = [{shutdown, Reason}|Postponed], return(State#state{postponed = [{shutdown, Reason}|Postponed]}).
return(State#state{postponed = Postponed1, stop_reason = Reason}).
return(State = #state{postponed = []}) -> return(State = #state{postponed = []}) ->
{ok, State}; {ok, State};