@@ -191,14 +191,16 @@ def _has_mcast_record_in_last_second(self, record: DNSRecord) -> bool:
191191class QueryHandler :
192192 """Query the ServiceRegistry."""
193193
194- __slots__ = ("zc" , "registry" , "cache" , "question_history" )
194+ __slots__ = ("zc" , "registry" , "cache" , "question_history" , "out_queue" , "out_delay_queue" )
195195
196196 def __init__ (self , zc : 'Zeroconf' ) -> None :
197197 """Init the query handler."""
198198 self .zc = zc
199199 self .registry = zc .registry
200200 self .cache = zc .cache
201201 self .question_history = zc .question_history
202+ self .out_queue = zc .out_queue
203+ self .out_delay_queue = zc .out_delay_queue
202204
203205 def _add_service_type_enumeration_query_answers (
204206 self , types : List [str ], answer_set : _AnswerWithAdditionalsType , known_answers : DNSRRSet
@@ -301,7 +303,7 @@ def async_response( # pylint: disable=unused-argument
301303 """
302304 strategies : List [_AnswerStrategy ] = []
303305 for msg in msgs :
304- for question in msg .questions :
306+ for question in msg ._questions :
305307 strategies .extend (self ._get_answer_strategies (question ))
306308
307309 if not strategies :
@@ -311,7 +313,8 @@ def async_response( # pylint: disable=unused-argument
311313 return None
312314
313315 is_probe = False
314- questions = msg .questions
316+ msg = msgs [0 ]
317+ questions = msg ._questions
315318 # Only decode known answers if we are not a probe and we have
316319 # at least one answer strategy
317320 answers : List [DNSRecord ] = []
@@ -321,7 +324,6 @@ def async_response( # pylint: disable=unused-argument
321324 else :
322325 answers .extend (msg .answers ())
323326
324- msg = msgs [0 ]
325327 query_res = _QueryResponse (self .cache , questions , is_probe , msg .now )
326328 known_answers = DNSRRSet (answers )
327329 known_answers_set : Optional [Set [DNSRecord ]] = None
@@ -412,13 +414,12 @@ def handle_assembled_query(
412414 packet will be in packets.
413415 """
414416 first_packet = packets [0 ]
415- now = first_packet .now
416417 ucast_source = port != _MDNS_PORT
417418 question_answers = self .async_response (packets , ucast_source )
418- if not question_answers :
419+ if question_answers is None :
419420 return
420421 if question_answers .ucast :
421- questions = first_packet .questions
422+ questions = first_packet ._questions
422423 id_ = first_packet .id
423424 out = construct_outgoing_unicast_answers (question_answers .ucast , ucast_source , questions , id_ )
424425 # When sending unicast, only send back the reply
@@ -428,11 +429,9 @@ def handle_assembled_query(
428429 if question_answers .mcast_now :
429430 self .zc .async_send (construct_outgoing_multicast_answers (question_answers .mcast_now ))
430431 if question_answers .mcast_aggregate :
431- out_queue = self .zc .out_queue
432- out_queue .async_add (now , question_answers .mcast_aggregate )
432+ self .out_queue .async_add (first_packet .now , question_answers .mcast_aggregate )
433433 if question_answers .mcast_aggregate_last_second :
434434 # https://datatracker.ietf.org/doc/html/rfc6762#section-14
435435 # If we broadcast it in the last second, we have to delay
436436 # at least a second before we send it again
437- out_delay_queue = self .zc .out_delay_queue
438- out_delay_queue .async_add (now , question_answers .mcast_aggregate_last_second )
437+ self .out_delay_queue .async_add (first_packet .now , question_answers .mcast_aggregate_last_second )
0 commit comments