Fix bug that no update message expiry interval (#2101)
This commit is contained in:
parent
f7596b8131
commit
edf0ded9f3
|
@ -23,6 +23,7 @@
|
||||||
-export([set_headers/2]).
|
-export([set_headers/2]).
|
||||||
-export([get_header/2, get_header/3, set_header/3]).
|
-export([get_header/2, get_header/3, set_header/3]).
|
||||||
-export([is_expired/1, update_expiry/1]).
|
-export([is_expired/1, update_expiry/1]).
|
||||||
|
-export([remove_topic_alias/1]).
|
||||||
-export([format/1]).
|
-export([format/1]).
|
||||||
|
|
||||||
-type(flag() :: atom()).
|
-type(flag() :: atom()).
|
||||||
|
@ -109,6 +110,9 @@ update_expiry(Msg = #message{headers = #{'Message-Expiry-Interval' := Interval},
|
||||||
|
|
||||||
update_expiry(Msg) -> Msg.
|
update_expiry(Msg) -> Msg.
|
||||||
|
|
||||||
|
remove_topic_alias(Msg = #message{headers = Headers}) ->
|
||||||
|
Msg#message{headers = maps:remove('Topic-Alias', Headers)}.
|
||||||
|
|
||||||
%% MilliSeconds
|
%% MilliSeconds
|
||||||
elapsed(Since) ->
|
elapsed(Since) ->
|
||||||
max(0, timer:now_diff(os:timestamp(), Since) div 1000).
|
max(0, timer:now_diff(os:timestamp(), Since) div 1000).
|
||||||
|
|
|
@ -617,11 +617,11 @@ deliver({connack, ?RC_SUCCESS, SP}, PState = #pstate{zone = Zone,
|
||||||
deliver({connack, ReasonCode, SP}, PState) ->
|
deliver({connack, ReasonCode, SP}, PState) ->
|
||||||
send(?CONNACK_PACKET(ReasonCode, SP), PState);
|
send(?CONNACK_PACKET(ReasonCode, SP), PState);
|
||||||
|
|
||||||
deliver({publish, PacketId, Msg = #message{headers = Headers}}, PState = #pstate{mountpoint = MountPoint}) ->
|
deliver({publish, PacketId, Msg}, PState = #pstate{mountpoint = MountPoint}) ->
|
||||||
_ = emqx_hooks:run('message.delivered', [credentials(PState)], Msg),
|
_ = emqx_hooks:run('message.delivered', [credentials(PState)], Msg),
|
||||||
Msg1 = emqx_message:update_expiry(Msg),
|
Msg1 = emqx_message:update_expiry(Msg),
|
||||||
Msg2 = emqx_mountpoint:unmount(MountPoint, Msg1),
|
Msg2 = emqx_mountpoint:unmount(MountPoint, Msg1),
|
||||||
send(emqx_packet:from_message(PacketId, Msg2#message{headers = maps:remove('Topic-Alias', Headers)}), PState);
|
send(emqx_packet:from_message(PacketId, emqx_message:remove_topic_alias(Msg2)), PState);
|
||||||
|
|
||||||
deliver({puback, PacketId, ReasonCode}, PState) ->
|
deliver({puback, PacketId, ReasonCode}, PState) ->
|
||||||
send(?PUBACK_PACKET(PacketId, ReasonCode), PState);
|
send(?PUBACK_PACKET(PacketId, ReasonCode), PState);
|
||||||
|
|
Loading…
Reference in New Issue