Fix QoS tuning

This commit is contained in:
Feng Lee 2018-08-06 17:09:14 +08:00
parent 7d0cba9427
commit 645c971a07
1 changed files with 4 additions and 6 deletions

View File

@ -758,14 +758,12 @@ dequeue2(State = #state{mqueue = Q}) ->
tune_qos(Topic, Msg = #message{qos = PubQoS},
#state{subscriptions = SubMap, upgrade_qos = UpgradeQoS}) ->
case maps:find(Topic, SubMap) of
{ok, SubQoS} when UpgradeQoS andalso (SubQoS > PubQoS) ->
{ok, #{qos := SubQoS}} when UpgradeQoS andalso (SubQoS > PubQoS) ->
Msg#message{qos = SubQoS};
{ok, SubQoS} when (not UpgradeQoS) andalso (SubQoS < PubQoS) ->
{ok, #{qos := SubQoS}} when (not UpgradeQoS) andalso (SubQoS < PubQoS) ->
Msg#message{qos = SubQoS};
{ok, _} ->
Msg;
error ->
Msg
{ok, _} -> Msg;
error -> Msg
end.
%%------------------------------------------------------------------------------