Ensure the 'conn_state' be 'disconnected' after socket closed
This commit is contained in:
parent
7f730ffec6
commit
6233aa7d46
|
@ -737,9 +737,9 @@ handle_info({register, Attrs, Stats}, #channel{clientinfo = #{clientid := Client
|
|||
handle_info({sock_closed, _Reason}, Channel = #channel{conn_state = disconnected}) ->
|
||||
{ok, Channel};
|
||||
|
||||
handle_info({sock_closed, _Reason}, Channel = #channel{conninfo = ConnInfo,
|
||||
clientinfo = ClientInfo = #{zone := Zone},
|
||||
will_msg = WillMsg}) ->
|
||||
handle_info({sock_closed, Reason}, Channel = #channel{conninfo = ConnInfo,
|
||||
clientinfo = ClientInfo = #{zone := Zone},
|
||||
will_msg = WillMsg}) ->
|
||||
emqx_zone:enable_flapping_detect(Zone) andalso emqx_flapping:detect(ClientInfo),
|
||||
ConnInfo1 = ConnInfo#{disconnected_at => erlang:system_time(second)},
|
||||
Channel1 = Channel#channel{conninfo = ConnInfo1, conn_state = disconnected},
|
||||
|
@ -750,11 +750,11 @@ handle_info({sock_closed, _Reason}, Channel = #channel{conninfo = ConnInfo,
|
|||
end,
|
||||
case maps:get(expiry_interval, ConnInfo) of
|
||||
?UINT_MAX ->
|
||||
{ok, Channel2};
|
||||
{ok, {enter, disconnected}, Channel2};
|
||||
Int when Int > 0 ->
|
||||
{ok, ensure_timer(expire_timer, Channel2)};
|
||||
{ok, {enter, disconnected}, ensure_timer(expire_timer, Channel2)};
|
||||
_Other ->
|
||||
shutdown(closed, Channel2)
|
||||
shutdown(Reason, Channel2)
|
||||
end;
|
||||
|
||||
handle_info(Info, Channel) ->
|
||||
|
@ -1206,3 +1206,4 @@ shutdown(Reason, Channel) ->
|
|||
|
||||
shutdown(Reason, Packets, Channel) ->
|
||||
{stop, {shutdown, Reason}, Packets, Channel}.
|
||||
|
||||
|
|
|
@ -554,7 +554,7 @@ handle_info(sock_closed, State) ->
|
|||
|
||||
handle_info({close, Reason}, State) ->
|
||||
?LOG(debug, "Force close due to : ~p", [Reason]),
|
||||
{ok, close_socket(State)};
|
||||
handle_info({sock_closed, Reason}, close_socket(State));
|
||||
|
||||
handle_info(Info, State = #state{channel = Channel}) ->
|
||||
handle_return(emqx_channel:handle_info(Info, Channel), State).
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
all() -> emqx_ct:all(?MODULE).
|
||||
|
||||
init_per_suite(Config) ->
|
||||
ok = emqx_logger:set_log_level(emergency),
|
||||
Config.
|
||||
|
||||
end_per_suite(_Config) ->
|
||||
|
|
Loading…
Reference in New Issue