Skip to content

Commit 3b0fd36

Browse files
committed
Addressing the issue of numeric overflow with expiration values.
1 parent d92a423 commit 3b0fd36

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clients.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func (cl *Client) ClearInflights(now, maximumExpiry int64) []uint16 {
337337
}
338338

339339
for _, tk := range cl.State.Inflight.GetAll(false) {
340-
if (tk.Expiry > 0 && tk.Expiry < now) || tk.Created+maximumExpiry < now {
340+
if (tk.Expiry > 0 && tk.Expiry < now) || tk.Created < now-maximumExpiry {
341341
if ok := cl.State.Inflight.Delete(tk.PacketID); ok {
342342
cl.ops.hooks.OnQosDropped(cl, tk)
343343
atomic.AddInt64(&cl.ops.info.Inflight, -1)

server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1604,7 +1604,7 @@ func (s *Server) clearExpiredRetainedMessages(now int64) {
16041604
}
16051605

16061606
for filter, pk := range s.Topics.Retained.GetAll() {
1607-
if (pk.Expiry > 0 && pk.Expiry < now) || pk.Created+s.Options.Capabilities.MaximumMessageExpiryInterval < now {
1607+
if (pk.Expiry > 0 && pk.Expiry < now) || pk.Created < now-s.Options.Capabilities.MaximumMessageExpiryInterval {
16081608
s.Topics.Retained.Delete(filter)
16091609
s.hooks.OnRetainedExpired(filter)
16101610
}

0 commit comments

Comments
 (0)