Avoid process crash report for arbitrary exit reason
This commit is contained in:
parent
ebea3cc392
commit
47a192ee34
|
@ -357,7 +357,7 @@ handle_in(?DISCONNECT_PACKET(ReasonCode, Properties), Channel = #channel{conninf
|
||||||
OldInterval == 0 andalso Interval > OldInterval ->
|
OldInterval == 0 andalso Interval > OldInterval ->
|
||||||
handle_out({disconnect, ?RC_PROTOCOL_ERROR}, Channel1);
|
handle_out({disconnect, ?RC_PROTOCOL_ERROR}, Channel1);
|
||||||
Interval == 0 ->
|
Interval == 0 ->
|
||||||
{stop, ReasonName, Channel1};
|
shutdown(ReasonName, Channel1);
|
||||||
true ->
|
true ->
|
||||||
Channel2 = Channel1#channel{conninfo = ConnInfo#{expiry_interval => Interval}},
|
Channel2 = Channel1#channel{conninfo = ConnInfo#{expiry_interval => Interval}},
|
||||||
{close, ReasonName, Channel2}
|
{close, ReasonName, Channel2}
|
||||||
|
@ -369,9 +369,9 @@ handle_in(?AUTH_PACKET(), Channel) ->
|
||||||
handle_in({frame_error, Reason}, Channel = #channel{state = FsmState}) ->
|
handle_in({frame_error, Reason}, Channel = #channel{state = FsmState}) ->
|
||||||
case FsmState of
|
case FsmState of
|
||||||
#{state_name := initialized} ->
|
#{state_name := initialized} ->
|
||||||
{stop, {shutdown, Reason}, Channel};
|
shutdown(Reason, Channel);
|
||||||
#{state_name := connecting} ->
|
#{state_name := connecting} ->
|
||||||
{stop, {shutdown, Reason}, ?CONNACK_PACKET(?RC_MALFORMED_PACKET), Channel};
|
shutdown(Reason, ?CONNACK_PACKET(?RC_MALFORMED_PACKET), Channel);
|
||||||
#{state_name := connected} ->
|
#{state_name := connected} ->
|
||||||
handle_out({disconnect, ?RC_MALFORMED_PACKET}, Channel);
|
handle_out({disconnect, ?RC_MALFORMED_PACKET}, Channel);
|
||||||
#{state_name := disconnected} ->
|
#{state_name := disconnected} ->
|
||||||
|
@ -564,7 +564,7 @@ handle_out({connack, ReasonCode, _ConnPkt}, Channel = #channel{conninfo = ConnIn
|
||||||
_Ver -> emqx_reason_codes:compat(connack, ReasonCode)
|
_Ver -> emqx_reason_codes:compat(connack, ReasonCode)
|
||||||
end,
|
end,
|
||||||
Reason = emqx_reason_codes:name(ReasonCode1, ProtoVer),
|
Reason = emqx_reason_codes:name(ReasonCode1, ProtoVer),
|
||||||
{stop, {shutdown, Reason}, ?CONNACK_PACKET(ReasonCode1), Channel};
|
shutdown(Reason, ?CONNACK_PACKET(ReasonCode1), Channel);
|
||||||
|
|
||||||
handle_out({deliver, Delivers}, Channel = #channel{state = #{state_name := disconnected},
|
handle_out({deliver, Delivers}, Channel = #channel{state = #{state_name := disconnected},
|
||||||
session = Session}) ->
|
session = Session}) ->
|
||||||
|
@ -646,9 +646,9 @@ handle_out({disconnect, ReasonCode, ReasonName},
|
||||||
expiry_interval := ExpiryInterval}}) ->
|
expiry_interval := ExpiryInterval}}) ->
|
||||||
case {ExpiryInterval, ProtoVer} of
|
case {ExpiryInterval, ProtoVer} of
|
||||||
{0, ?MQTT_PROTO_V5} ->
|
{0, ?MQTT_PROTO_V5} ->
|
||||||
{stop, ReasonName, ?DISCONNECT_PACKET(ReasonCode), Channel};
|
shutdown(ReasonName, ?DISCONNECT_PACKET(ReasonCode), Channel);
|
||||||
{0, _Ver} ->
|
{0, _Ver} ->
|
||||||
{stop, ReasonName, Channel};
|
shutdown(ReasonName, Channel);
|
||||||
{?UINT_MAX, ?MQTT_PROTO_V5} ->
|
{?UINT_MAX, ?MQTT_PROTO_V5} ->
|
||||||
{close, ReasonName, ?DISCONNECT_PACKET(ReasonCode), Channel};
|
{close, ReasonName, ?DISCONNECT_PACKET(ReasonCode), Channel};
|
||||||
{?UINT_MAX, _Ver} ->
|
{?UINT_MAX, _Ver} ->
|
||||||
|
@ -1206,3 +1206,5 @@ flag(false) -> 0.
|
||||||
shutdown(Reason, Channel) ->
|
shutdown(Reason, Channel) ->
|
||||||
{stop, {shutdown, Reason}, Channel}.
|
{stop, {shutdown, Reason}, Channel}.
|
||||||
|
|
||||||
|
shutdown(Reason, Packets, Channel) ->
|
||||||
|
{stop, {shutdown, Reason}, Packets, Channel}.
|
||||||
|
|
|
@ -164,7 +164,7 @@ t_handle_pingreq(_) ->
|
||||||
t_handle_disconnect(_) ->
|
t_handle_disconnect(_) ->
|
||||||
with_channel(
|
with_channel(
|
||||||
fun(Channel) ->
|
fun(Channel) ->
|
||||||
{stop, normal, Channel1} = handle_in(?DISCONNECT_PACKET(?RC_SUCCESS), Channel),
|
{stop, {shutdown, normal}, Channel1} = handle_in(?DISCONNECT_PACKET(?RC_SUCCESS), Channel),
|
||||||
?assertEqual(undefined, emqx_channel:info(will_msg, Channel1))
|
?assertEqual(undefined, emqx_channel:info(will_msg, Channel1))
|
||||||
end).
|
end).
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ t_handle_in_auth(_) ->
|
||||||
with_channel(
|
with_channel(
|
||||||
fun(Channel) ->
|
fun(Channel) ->
|
||||||
Packet = ?DISCONNECT_PACKET(?RC_IMPLEMENTATION_SPECIFIC_ERROR),
|
Packet = ?DISCONNECT_PACKET(?RC_IMPLEMENTATION_SPECIFIC_ERROR),
|
||||||
{stop, implementation_specific_error, Packet, Channel} = handle_in(?AUTH_PACKET(), Channel)
|
{stop, {shutdown, implementation_specific_error}, Packet, Channel} = handle_in(?AUTH_PACKET(), Channel)
|
||||||
end).
|
end).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue