Skip to content

Add cancellable DTLS session interruption - #35

Open
Jason-Morcos wants to merge 3 commits into
QuiteYellow:mainfrom
Moballo-LLC:codex/py-08b-session-interruption
Open

Add cancellable DTLS session interruption#35
Jason-Morcos wants to merge 3 commits into
QuiteYellow:mainfrom
Moballo-LLC:codex/py-08b-session-interruption

Conversation

@Jason-Morcos

Copy link
Copy Markdown
Contributor

Problem

A caller can bound connect(), but it cannot cancel an attempt that is no longer needed. Shutdown also cannot distinguish between stopping new work while preserving an established DTLS session for normal close and immediately dropping local I/O.

Changes

  • Add connect(cancel=...) using a threading.Event.
  • Observe cancellation between setup phases and every 100 ms during network receive, without changing the existing two-second handshake retry cadence.
  • Track the in-progress handshake socket so cancellation, quiesce, abort, or close cannot leave it blocked.
  • Add quiesce_for_close() to stop new work, interrupt an in-progress connection, and wake response waiters while retaining an established session for close().
  • Add abort() to close established local I/O immediately.
  • Serialize pending-request registration and wakeup so shutdown cannot miss a waiter.
  • Raise the existing SessionClosedError for cancellation and shutdown interruption.

Synchronous TLS context and endpoint setup are checked immediately before and after each phase; Python cannot preempt those calls while they are executing.

Validation

  • 213 tests with current dependencies.
  • 213 tests on Python 3.11 with pyOpenSSL 23.1.
  • All 1,070 LocalThings tests against this checkout.
  • 25 repeated lifecycle stress runs.
  • Focused Ruff, compile, share-safety, distribution-content checks, and isolated wheel/sdist imports.

Tests cover pre-cancellation, cancellation during every published handshake phase, retry-cadence preservation, cancellation after reported success, retry after per-call cancellation, quiescing an in-flight socket, atomic pending-request wakeup, blocked send/read interruption, repeated abort, and reader/pacing shutdown.

Stack

Depends on #34, which depends on #33. Until those PRs merge, GitHub includes their commits in this PR comparison; the new commit for this slice is ecc963e.

Authenticated close-alert flushing and session-generation invalidation remain separate follow-ups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant