Update emqx_channel.erl
This commit is contained in:
parent
f3a92f35f6
commit
44d53ecb33
|
@ -328,25 +328,21 @@ handle_in(?PACKET(?PINGREQ), Channel) ->
|
||||||
|
|
||||||
handle_in(?DISCONNECT_PACKET(RC, Properties), Channel = #channel{session = Session, protocol = Protocol}) ->
|
handle_in(?DISCONNECT_PACKET(RC, Properties), Channel = #channel{session = Session, protocol = Protocol}) ->
|
||||||
OldInterval = emqx_session:info(expiry_interval, Session),
|
OldInterval = emqx_session:info(expiry_interval, Session),
|
||||||
Interval = maps:get('Session-Expiry-Interval', case Properties of
|
Interval = get_property('Session-Expiry-Interval', Properties, OldInterval),
|
||||||
undefined -> #{};
|
|
||||||
_ -> Properties
|
|
||||||
end, OldInterval),
|
|
||||||
case OldInterval =:= 0 andalso Interval =/= OldInterval of
|
case OldInterval =:= 0 andalso Interval =/= OldInterval of
|
||||||
true ->
|
true ->
|
||||||
handle_out({disconnect, ?RC_PROTOCOL_ERROR}, Channel);
|
handle_out({disconnect, ?RC_PROTOCOL_ERROR}, Channel);
|
||||||
false ->
|
false ->
|
||||||
NChannel = ensure_disconnected(case RC of
|
Channel1 = case RC of
|
||||||
?RC_SUCCESS ->
|
?RC_SUCCESS -> Channel#channel{protocol = emqx_protocol:clear_will_msg(Protocol)};
|
||||||
Channel#channel{protocol = emqx_protocol:clear_will_msg(Protocol),
|
_ -> Channel
|
||||||
session = emqx_session:update_expiry_interval(Interval, Session)};
|
end,
|
||||||
_ -> Channel#channel{session = emqx_session:update_expiry_interval(Interval, Session)}
|
Channel2 = ensure_disconnected(Channel1#channel{session = emqx_session:update_expiry_interval(Interval, Session)}),
|
||||||
end),
|
|
||||||
case Interval of
|
case Interval of
|
||||||
?UINT_MAX ->
|
?UINT_MAX ->
|
||||||
{ok, ensure_timer(will_timer, NChannel)};
|
{ok, ensure_timer(will_timer, Channel2)};
|
||||||
Int when Int > 0 ->
|
Int when Int > 0 ->
|
||||||
{ok, ensure_timer([will_timer, expire_timer], NChannel)};
|
{ok, ensure_timer([will_timer, expire_timer], Channel2)};
|
||||||
_Other ->
|
_Other ->
|
||||||
Reason = case RC of
|
Reason = case RC of
|
||||||
?RC_SUCCESS -> normal;
|
?RC_SUCCESS -> normal;
|
||||||
|
@ -354,7 +350,7 @@ handle_in(?DISCONNECT_PACKET(RC, Properties), Channel = #channel{session = Sessi
|
||||||
Ver = emqx_protocol:info(proto_ver, Protocol),
|
Ver = emqx_protocol:info(proto_ver, Protocol),
|
||||||
emqx_reason_codes:name(RC, Ver)
|
emqx_reason_codes:name(RC, Ver)
|
||||||
end,
|
end,
|
||||||
{stop, {shutdown, Reason}, NChannel}
|
{stop, {shutdown, Reason}, Channel2}
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue