fix(protocol): retain completed DTLS handshakes
This commit is contained in:
@@ -34,14 +34,16 @@ def _drive_dtls_handshake(
|
||||
bounded only by its deadline, while the diagnostic probe retains its
|
||||
explicit retry budget.
|
||||
|
||||
Return ``True`` only when the handshake completes before the deadline.
|
||||
TLS and socket failures are left to the caller to classify.
|
||||
Return ``True`` once OpenSSL reports the handshake complete. The deadline
|
||||
prevents another setup, retry, or network-wait iteration; it does not tear
|
||||
down a session that completed while ``do_handshake()`` was running. TLS and
|
||||
socket failures are left to the caller to classify.
|
||||
"""
|
||||
retransmits = 0
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
connection.do_handshake()
|
||||
return time.monotonic() < deadline
|
||||
return True
|
||||
except SSL.WantReadError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -322,13 +322,15 @@ class DtlsCoapSession:
|
||||
timeout: float | None = None,
|
||||
cancel: ConnectCancellation | None = None,
|
||||
):
|
||||
"""Perform a cancellable DTLS handshake within a monotonic deadline.
|
||||
"""Perform a cancellable DTLS handshake using a monotonic deadline.
|
||||
|
||||
``timeout`` overrides ``HANDSHAKE_TIMEOUT_S`` for this call. OpenSSL
|
||||
owns DTLS retransmission timing while every receive is capped by the
|
||||
remaining budget, so wall-clock adjustments cannot change the bound.
|
||||
A ``ConnectCancellation`` wakes the network wait immediately and does
|
||||
not alter an already established session.
|
||||
Once OpenSSL reports completion, that completed session is retained
|
||||
even if the call returns just after the deadline. A
|
||||
``ConnectCancellation`` wakes the network wait immediately and does not
|
||||
alter an already established session.
|
||||
"""
|
||||
handshake_timeout = _validate_handshake_timeout(
|
||||
timeout, self.HANDSHAKE_TIMEOUT_S)
|
||||
|
||||
Reference in New Issue
Block a user