fix(protocol): keep completed sessions on late cancel

This commit is contained in:
Jason Morcos
2026-08-15 11:44:24 -07:00
parent 31be87061a
commit 627fcb19da
2 changed files with 40 additions and 3 deletions
+2 -1
View File
@@ -382,6 +382,7 @@ class DtlsCoapSession:
io_failed = False
cancelled = False
interrupted = False
completed = False
try:
try:
completed = _drive_dtls_handshake(
@@ -403,7 +404,7 @@ class DtlsCoapSession:
finally:
if wake_subscription is not None:
interrupted = cancel._unsubscribe(*wake_subscription)
if cancelled or interrupted:
if cancelled or (interrupted and not completed):
sock.close()
raise SessionClosedError()
if backend_failed: