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}, tune_qos(Topic, Msg = #message{qos = PubQoS},
#state{subscriptions = SubMap, upgrade_qos = UpgradeQoS}) -> #state{subscriptions = SubMap, upgrade_qos = UpgradeQoS}) ->
case maps:find(Topic, SubMap) of 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}; 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}; Msg#message{qos = SubQoS};
{ok, _} -> {ok, _} -> Msg;
Msg; error -> Msg
error ->
Msg
end. end.
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------