Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/zeroconf/_cache.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cdef class DNSCache:
@cython.locals(
record=DNSRecord,
)
cpdef async_expire(self, float now)
cpdef async_expire(self, double now)

@cython.locals(
records=cython.dict,
Expand Down Expand Up @@ -68,6 +68,6 @@ cdef class DNSCache:

@cython.locals(
record=DNSRecord,
created_float=cython.float,
created_double=double,
)
cpdef async_mark_unique_records_older_than_1s_to_expire(self, cython.set unique_types, object answers, float now)
cpdef async_mark_unique_records_older_than_1s_to_expire(self, cython.set unique_types, object answers, double now)
4 changes: 2 additions & 2 deletions src/zeroconf/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def async_mark_unique_records_older_than_1s_to_expire(
answers_rrset = set(answers)
for name, type_, class_ in unique_types:
for record in self.async_all_by_details(name, type_, class_):
created_float = record.created
if (now - created_float > _ONE_SECOND) and record not in answers_rrset:
created_double = record.created
if (now - created_double > _ONE_SECOND) and record not in answers_rrset:
# Expire in 1s
record.set_created_ttl(now, 1)
14 changes: 7 additions & 7 deletions src/zeroconf/_dns.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cdef class DNSQuestion(DNSEntry):
cdef class DNSRecord(DNSEntry):

cdef public cython.float ttl
cdef public cython.float created
cdef public double created

cdef bint _suppressed_by_answer(self, DNSRecord answer)

Expand All @@ -52,19 +52,19 @@ cdef class DNSRecord(DNSEntry):
)
cpdef bint suppressed_by(self, object msg)

cpdef get_remaining_ttl(self, cython.float now)
cpdef get_remaining_ttl(self, double now)

cpdef get_expiration_time(self, cython.uint percent)
cpdef double get_expiration_time(self, cython.uint percent)

cpdef bint is_expired(self, cython.float now)
cpdef bint is_expired(self, double now)

cpdef bint is_stale(self, cython.float now)
cpdef bint is_stale(self, double now)

cpdef bint is_recent(self, cython.float now)
cpdef bint is_recent(self, double now)

cpdef reset_ttl(self, DNSRecord other)

cpdef set_created_ttl(self, cython.float now, cython.float ttl)
cpdef set_created_ttl(self, double now, cython.float ttl)

cdef class DNSAddress(DNSRecord):

Expand Down
4 changes: 2 additions & 2 deletions src/zeroconf/_handlers/answers.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ cdef class QuestionAnswers:

cdef class AnswerGroup:

cdef public float send_after
cdef public float send_before
cdef public double send_after
cdef public double send_before
cdef public cython.dict answers


Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/_handlers/multicast_outgoing_queue.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cdef class MulticastOutgoingQueue:
cdef object _aggregation_delay

@cython.locals(last_group=AnswerGroup, random_int=cython.uint)
cpdef async_add(self, float now, cython.dict answers)
cpdef async_add(self, double now, cython.dict answers)

@cython.locals(pending=AnswerGroup)
cdef _remove_answers_from_queue(self, cython.dict answers)
Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/_handlers/record_manager.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cdef class RecordManager:
record=DNSRecord,
answers=cython.list,
maybe_entry=DNSRecord,
now_float=cython.float
now_double=double
)
cpdef async_updates_from_response(self, DNSIncoming msg)

Expand Down
6 changes: 3 additions & 3 deletions src/zeroconf/_handlers/record_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def async_updates_from_response(self, msg: DNSIncoming) -> None:
other_adds: List[DNSRecord] = []
removes: Set[DNSRecord] = set()
now = msg.now
now_float = now
now_double = now
unique_types: Set[Tuple[str, int, int]] = set()
cache = self.cache
answers = msg.answers()
Expand Down Expand Up @@ -113,7 +113,7 @@ def async_updates_from_response(self, msg: DNSIncoming) -> None:
record = cast(_UniqueRecordsType, record)

maybe_entry = cache.async_get_unique(record)
if not record.is_expired(now_float):
if not record.is_expired(now_double):
if maybe_entry is not None:
maybe_entry.reset_ttl(record)
else:
Expand All @@ -129,7 +129,7 @@ def async_updates_from_response(self, msg: DNSIncoming) -> None:
removes.add(record)

if unique_types:
cache.async_mark_unique_records_older_than_1s_to_expire(unique_types, answers, now_float)
cache.async_mark_unique_records_older_than_1s_to_expire(unique_types, answers, now_double)

if updates:
self.async_updates(now, updates)
Expand Down
6 changes: 3 additions & 3 deletions src/zeroconf/_listener.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ cdef class AsyncListener:
cdef ServiceRegistry _registry
cdef RecordManager _record_manager
cdef public cython.bytes data
cdef public cython.float last_time
cdef public double last_time
cdef public DNSIncoming last_message
cdef public object transport
cdef public object sock_description
cdef public cython.dict _deferred
cdef public cython.dict _timers

@cython.locals(now=cython.float, debug=cython.bint)
@cython.locals(now=double, debug=cython.bint)
cpdef datagram_received(self, cython.bytes bytes, cython.tuple addrs)

@cython.locals(msg=DNSIncoming)
cpdef _process_datagram_at_time(self, bint debug, cython.uint data_len, cython.float now, bytes data, cython.tuple addrs)
cpdef _process_datagram_at_time(self, bint debug, cython.uint data_len, double now, bytes data, cython.tuple addrs)

cdef _cancel_any_timers_for_addr(self, object addr)

Expand Down
6 changes: 3 additions & 3 deletions src/zeroconf/_protocol/outgoing.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cdef class DNSOutgoing:
index=cython.uint,
length=cython.uint
)
cdef cython.bint _write_record(self, DNSRecord record, float now)
cdef cython.bint _write_record(self, DNSRecord record, double now)

@cython.locals(class_=cython.uint)
cdef _write_record_class(self, DNSEntry record)
Expand All @@ -92,7 +92,7 @@ cdef class DNSOutgoing:

cdef bint _has_more_to_add(self, unsigned int questions_offset, unsigned int answer_offset, unsigned int authority_offset, unsigned int additional_offset)

cdef _write_ttl(self, DNSRecord record, float now)
cdef _write_ttl(self, DNSRecord record, double now)

@cython.locals(
labels=cython.list,
Expand Down Expand Up @@ -135,7 +135,7 @@ cdef class DNSOutgoing:

cpdef add_answer(self, DNSIncoming inp, DNSRecord record)

@cython.locals(now_float=cython.float)
@cython.locals(now_double=double)
cpdef add_answer_at_time(self, DNSRecord record, object now)

cpdef add_authorative_answer(self, DNSPointer record)
Expand Down
4 changes: 2 additions & 2 deletions src/zeroconf/_protocol/outgoing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def add_answer(self, inp: DNSIncoming, record: DNSRecord) -> None:

def add_answer_at_time(self, record: Optional[DNSRecord], now: Union[float, int]) -> None:
"""Adds an answer if it does not expire by a certain time"""
now_float = now
if record is not None and (now_float == 0 or not record.is_expired(now_float)):
now_double = now
if record is not None and (now_double == 0 or not record.is_expired(now_double)):
self.answers.append((record, now))

def add_authorative_answer(self, record: DNSPointer) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/zeroconf/_services/browser.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cdef class _DNSPointerOutgoingBucket:
@cython.locals(cache=DNSCache, question_history=QuestionHistory, record=DNSRecord, qu_question=bint)
cpdef generate_service_query(
object zc,
float now,
double now,
list type_,
bint multicast,
object question_type
Expand Down Expand Up @@ -73,7 +73,7 @@ cdef class _ServiceBrowserBase(RecordUpdateListener):
cpdef _enqueue_callback(self, object state_change, object type_, object name)

@cython.locals(record_update=RecordUpdate, record=DNSRecord, cache=DNSCache, service=DNSRecord, pointer=DNSPointer)
cpdef async_update_records(self, object zc, cython.float now, cython.list records)
cpdef async_update_records(self, object zc, double now, cython.list records)

cpdef cython.list _names_matching_types(self, object types)

Expand Down
12 changes: 6 additions & 6 deletions src/zeroconf/_services/info.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ cdef class ServiceInfo(RecordUpdateListener):
cdef public cython.set _get_address_and_nsec_records_cache

@cython.locals(record_update=RecordUpdate, update=bint, cache=DNSCache)
cpdef async_update_records(self, object zc, cython.float now, cython.list records)
cpdef async_update_records(self, object zc, double now, cython.list records)

@cython.locals(cache=DNSCache)
cpdef bint _load_from_cache(self, object zc, cython.float now)
cpdef bint _load_from_cache(self, object zc, double now)

@cython.locals(length="unsigned char", index="unsigned int", key_value=bytes, key_sep_value=tuple)
cdef void _unpack_text_into_properties(self)
Expand All @@ -79,21 +79,21 @@ cdef class ServiceInfo(RecordUpdateListener):
cdef _set_text(self, cython.bytes text)

@cython.locals(record=DNSAddress)
cdef _get_ip_addresses_from_cache_lifo(self, object zc, cython.float now, object type)
cdef _get_ip_addresses_from_cache_lifo(self, object zc, double now, object type)

@cython.locals(
dns_service_record=DNSService,
dns_text_record=DNSText,
dns_address_record=DNSAddress
)
cdef bint _process_record_threadsafe(self, object zc, DNSRecord record, cython.float now)
cdef bint _process_record_threadsafe(self, object zc, DNSRecord record, double now)

@cython.locals(cache=DNSCache)
cdef cython.list _get_address_records_from_cache_by_type(self, object zc, object _type)

cdef _set_ipv4_addresses_from_cache(self, object zc, object now)
cdef _set_ipv4_addresses_from_cache(self, object zc, double now)

cdef _set_ipv6_addresses_from_cache(self, object zc, object now)
cdef _set_ipv6_addresses_from_cache(self, object zc, double now)

cdef cython.list _ip_addresses_by_version_value(self, object version_value)

Expand Down
2 changes: 1 addition & 1 deletion src/zeroconf/_updates.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import cython

cdef class RecordUpdateListener:

cpdef async_update_records(self, object zc, cython.float now, cython.list records)
cpdef async_update_records(self, object zc, double now, cython.list records)

cpdef async_update_records_complete(self)
2 changes: 1 addition & 1 deletion src/zeroconf/_utils/time.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

cpdef current_time_millis()
cpdef double current_time_millis()

cpdef millis_to_seconds(object millis)