Skip to content

Commit 4d4d106

Browse files
committed
fix: tweaks
1 parent 0150b9a commit 4d4d106

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/zeroconf/_protocol/outgoing.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ cdef class DNSOutgoing:
100100
cpdef _write_utf(self, cython.str value)
101101

102102
@cython.locals(
103+
debug_enable=bint,
103104
questions_offset=object,
104105
answer_offset=object,
105106
authority_offset=object,

src/zeroconf/_protocol/outgoing.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,16 @@ def packets(self) -> List[bytes]:
428428
first_time = True
429429
debug_enable = LOGGING_IS_ENABLED_FOR(LOGGING_DEBUG)
430430

431-
while first_time or self._has_more_to_add(
432-
questions_offset, answer_offset, authority_offset, additional_offset
431+
while (
432+
first_time is True
433+
or self._has_more_to_add(questions_offset, answer_offset, authority_offset, additional_offset)
434+
is True
433435
):
434-
first_time = False
436+
if first_time:
437+
first_time = False
438+
else:
439+
self._reset_for_next_packet()
440+
435441
if debug_enable:
436442
log.debug(
437443
"offsets = questions=%d, answers=%d, authorities=%d, additionals=%d",
@@ -471,8 +477,12 @@ def packets(self) -> List[bytes]:
471477
additional_offset,
472478
)
473479

474-
if self.is_query() and self._has_more_to_add(
475-
questions_offset, answer_offset, authority_offset, additional_offset
480+
if (
481+
self.is_query() is True
482+
and self._has_more_to_add(
483+
questions_offset, answer_offset, authority_offset, additional_offset
484+
)
485+
is True
476486
):
477487
# https://datatracker.ietf.org/doc/html/rfc6762#section-7.2
478488
if debug_enable: # pragma: no branch
@@ -487,7 +497,6 @@ def packets(self) -> List[bytes]:
487497
self._insert_short_at_start(self.id)
488498

489499
self.packets_data.append(b''.join(self.data))
490-
self._reset_for_next_packet()
491500

492501
if (
493502
not questions_written

0 commit comments

Comments
 (0)