fix(mqtt_sn): after receiving publish in `idle mode` the gateway may panic

the `emqx_sn_gateway` will return `{keep_state, Timeout}` when received publish in `idle mode`, this is an incorrect format of `gen_statem` state return result, this return will replace the `state data` by the `Timeout`, the fix is to change it to `{keep_state_and_data, Timeout}`
This commit is contained in:
firest 2022-09-26 16:46:05 +08:00
parent 5b14d7f709
commit 0a3c8d035c
1 changed files with 2 additions and 2 deletions

View File

@ -208,7 +208,7 @@ idle(cast, {incoming, ?SN_DISCONNECT_MSG(_Duration)}, State) ->
idle(cast, {incoming, ?SN_PUBLISH_MSG(_Flag, _TopicId, _MsgId, _Data)}, State = #state{enable_qos3 = false}) -> idle(cast, {incoming, ?SN_PUBLISH_MSG(_Flag, _TopicId, _MsgId, _Data)}, State = #state{enable_qos3 = false}) ->
?LOG(debug, "The enable_qos3 is false, ignore the received publish with QoS=-1 in idle mode!"), ?LOG(debug, "The enable_qos3 is false, ignore the received publish with QoS=-1 in idle mode!"),
{keep_state, State#state.idle_timeout}; {keep_state_and_data, State#state.idle_timeout};
idle(cast, {incoming, ?SN_PUBLISH_MSG(#mqtt_sn_flags{qos = ?QOS_NEG1, idle(cast, {incoming, ?SN_PUBLISH_MSG(#mqtt_sn_flags{qos = ?QOS_NEG1,
topic_id_type = TopicIdType topic_id_type = TopicIdType
@ -226,7 +226,7 @@ idle(cast, {incoming, ?SN_PUBLISH_MSG(#mqtt_sn_flags{qos = ?QOS_NEG1,
ok ok
end, end,
?LOG(debug, "Client id=~p receives a publish with QoS=-1 in idle mode!", [ClientId]), ?LOG(debug, "Client id=~p receives a publish with QoS=-1 in idle mode!", [ClientId]),
{keep_state, State#state.idle_timeout}; {keep_state_and_data, State#state.idle_timeout};
idle(cast, {incoming, PingReq = ?SN_PINGREQ_MSG(_ClientId)}, State) -> idle(cast, {incoming, PingReq = ?SN_PINGREQ_MSG(_ClientId)}, State) ->
handle_ping(PingReq, State); handle_ping(PingReq, State);