From 8a908b43d59fd3dde55ce735861c7a90f090ecc2 Mon Sep 17 00:00:00 2001 From: Feng Date: Sat, 4 Jun 2016 12:07:54 +0800 Subject: [PATCH] Fix the incompatible Qos --- src/emqttd_parser.erl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/emqttd_parser.erl b/src/emqttd_parser.erl index 7ad1a0f50..1590ed0f8 100644 --- a/src/emqttd_parser.erl +++ b/src/emqttd_parser.erl @@ -44,10 +44,10 @@ limit(Opts) -> -> {ok, mqtt_packet()} | {error, any()} | {more, fun()}). parse(<<>>, {none, Limit}) -> {more, fun(Bin) -> parse(Bin, {none, Limit}) end}; -parse(<>, {none, Limit}) -> - parse_remaining_len(Rest, #mqtt_packet_header{type = PacketType, +parse(<>, {none, Limit}) -> + parse_remaining_len(Rest, #mqtt_packet_header{type = Type, dup = bool(Dup), - qos = QoS, + qos = fixqos(Type, QoS), retain = bool(Retain)}, Limit); parse(Bin, Cont) -> Cont(Bin). @@ -218,3 +218,9 @@ bool(1) -> true. protocol_name_approved(Ver, Name) -> lists:member({Ver, Name}, ?PROTOCOL_NAMES). +%% Fix Issue#575 +fixqos(?PUBREL, 0) -> 1; +fixqos(?SUBSCRIBE, 0) -> 1; +fixqos(?UNSUBSCRIBE, 0) -> 1; +fixqos(_Type, QoS) -> QoS. +