Skip to content

Commit

Permalink
Fix issue#1833 and #1834
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercl committed Sep 21, 2018
1 parent 3822ff9 commit 9278707
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/emqx_protocol.erl
Expand Up @@ -410,9 +410,17 @@ process_packet(?UNSUBSCRIBE_PACKET(PacketId, Properties, RawTopicFilters),
process_packet(?PACKET(?PINGREQ), PState) ->
send(?PACKET(?PINGRESP), PState);

process_packet(?DISCONNECT_PACKET(?RC_SUCCESS), PState) ->
%% Clean willmsg
{stop, normal, PState#pstate{will_msg = undefined}};
process_packet(?DISCONNECT_PACKET(?RC_SUCCESS, #{'Session-Expiry-Interval' := Interval}),
PState = #pstate{session = SPid, conn_props = #{'Session-Expiry-Interval' := OldInterval}}) ->
case Interval =/= 0 andalso OldInterval =:= 0 of
true ->
deliver({disconnect, ?RC_PROTOCOL_ERROR}, PState),
{error, protocol_error, PState};
false ->
emqx_session:update_expiry_interval(SPid, Interval),
%% Clean willmsg
{stop, normal, PState#pstate{will_msg = undefined}}
end;
process_packet(?DISCONNECT_PACKET(_), PState) ->
{stop, normal, PState}.

Expand Down

0 comments on commit 9278707

Please sign in to comment.