Skip to content

Commit 1b035fd

Browse files
committed
fix: refresh LRU on suppression hit, restore cdef constants
1 parent 6fe028c commit 1b035fd

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

src/zeroconf/_listener.pxd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ cdef object DEBUG_ENABLED
1313
cdef bint TYPE_CHECKING
1414

1515
cdef cython.uint _MAX_MSG_ABSOLUTE
16+
cdef cython.uint _DUPLICATE_PACKET_SUPPRESSION_INTERVAL
17+
cdef cython.uint _RECENT_PACKETS_MAX
1618

1719

1820
cdef class AsyncListener:

src/zeroconf/_listener.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ def _process_datagram_at_time(
121121
and (now - _DUPLICATE_PACKET_SUPPRESSION_INTERVAL) < recent[0]
122122
and not recent[1]
123123
):
124+
# Refresh LRU position so an actively-replayed payload is not
125+
# evicted by _RECENT_PACKETS_MAX distinct neighbours arriving
126+
# within the suppression interval. Preserve the original
127+
# (now, qu) tuple so the suppression window stays bounded
128+
# from the first observation rather than extending forever.
129+
del recent_packets[data]
130+
recent_packets[data] = recent
124131
# Guard against duplicate packets
125132
if debug:
126133
log.debug(

0 commit comments

Comments
 (0)