From 3ee8d5c5ca31837e45c347f46465c2c9b2c03f21 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Thu, 16 Jan 2020 16:49:13 +0800 Subject: [PATCH] Fix rap handling and keep the value of retain flag in bridge mode --- src/emqx_session.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/emqx_session.erl b/src/emqx_session.erl index 849491952..f4b906e39 100644 --- a/src/emqx_session.erl +++ b/src/emqx_session.erl @@ -516,12 +516,12 @@ enrich_subopts([{qos, SubQoS}|Opts], Msg = #message{qos = PubQoS}, enrich_subopts([{qos, SubQoS}|Opts], Msg = #message{qos = PubQoS}, Session = #session{upgrade_qos = false}) -> enrich_subopts(Opts, Msg#message{qos = min(SubQoS, PubQoS)}, Session); -enrich_subopts([{rap, _}|Opts], Msg = #message{headers = #{retained := true}}, Session) -> - enrich_subopts(Opts, emqx_message:set_flag(retain, true, Msg), Session); -enrich_subopts([{rap, 0}|Opts], Msg, Session) -> - enrich_subopts(Opts, emqx_message:set_flag(retain, false, Msg), Session); enrich_subopts([{rap, 1}|Opts], Msg, Session) -> enrich_subopts(Opts, Msg, Session); +enrich_subopts([{rap, 0}|Opts], Msg = #message{headers = #{retained := true}}, Session = #session{}) -> + enrich_subopts(Opts, Msg, Session); +enrich_subopts([{rap, 0}|Opts], Msg = #message{flags = Flags}, Session) -> + enrich_subopts(Opts, Msg#message{flags = maps:put(retain, false, Flags)}, Session); enrich_subopts([{subid, SubId}|Opts], Msg, Session) -> Msg1 = emqx_message:set_header('Subscription-Identifier', SubId, Msg), enrich_subopts(Opts, Msg1, Session).