The DNSCrypt forwarder tests' loopback relay stops cleanly on Windows when its receive is aborted #368

Merged
claude merged 1 commit from feature/367-relay-abort-on-windows into develop 2026-11-12 00:37:11 -05:00
Owner

The DNSCrypt forwarder tests' loopback relay now stops cleanly on Windows. This is a test-only change in DnsCryptForwarderClientTests.cs, and it fixes the one test that failed in the first test-windows run on develop (run 1310).

  • Cause: on Windows, closing a socket under a pending receive completes it with SocketException (OperationAborted, 995). The relay caught only OperationCanceledException and ObjectDisposedException, so a teardown race failed the test.
  • Fix: LoopbackRelay.EndedByStop treats an aborted or interrupted receive as a normal end only when the stop token is already cancelled. The relay cancels before it closes, so an abort before the stop still fails. All three relay loops use it.
  • The class no longer reserves and releases a port. Its listeners bind port 0 and read BoundPort; the harness binds UDP on port 0 and TCP on the same number, with a bounded retry.
  • Production check: no listener or client logs or faults on a 995 abort during a normal shutdown.

Verified: the coder showed it red on Lofnheim (7 of 9 fail with the close moved before the cancel). Ninlil.Dns.Server.Forwarding.Tests passed 258/258 in 20 runs by the coder and 10 by the verifier, on both Windows and Linux. The build has 0 warnings and csharpier is clean.

Closes #367
Refs #8

🤖 Generated with Claude Code

https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK

The DNSCrypt forwarder tests' loopback relay now stops cleanly on Windows. This is a test-only change in `DnsCryptForwarderClientTests.cs`, and it fixes the one test that failed in the first `test-windows` run on develop (run 1310). - **Cause:** on Windows, closing a socket under a pending receive completes it with `SocketException` (`OperationAborted`, 995). The relay caught only `OperationCanceledException` and `ObjectDisposedException`, so a teardown race failed the test. - **Fix:** `LoopbackRelay.EndedByStop` treats an aborted or interrupted receive as a normal end only when the stop token is already cancelled. The relay cancels before it closes, so an abort before the stop still fails. All three relay loops use it. - The class no longer reserves and releases a port. Its listeners bind port 0 and read `BoundPort`; the harness binds UDP on port 0 and TCP on the same number, with a bounded retry. - **Production check:** no listener or client logs or faults on a 995 abort during a normal shutdown. **Verified:** the coder showed it red on Lofnheim (7 of 9 fail with the close moved before the cancel). `Ninlil.Dns.Server.Forwarding.Tests` passed 258/258 in 20 runs by the coder and 10 by the verifier, on both Windows and Linux. The build has 0 warnings and csharpier is clean. Closes #367 Refs #8 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
The DNSCrypt forwarder tests' loopback relay treats a Windows aborted receive after its stop as a normal end, and its listeners bind OS-assigned ports
All checks were successful
Build / Pack and Push NuGet Packages (dhcp) (pull_request) Successful in -1m56s
Build / Pack and Push NuGet Packages (dns-core) (pull_request) Successful in -2m0s
Build / Stage Draft Release (push) Successful in -2m33s
Build / Pack and Push NuGet Packages (dns-server) (pull_request) Successful in -1m50s
Build / Pack and Push NuGet Packages (common) (push) Successful in -2m21s
Build / Pack and Push NuGet Packages (dhcp) (push) Successful in -1m58s
Build / Pack and Push NuGet Packages (dns-core) (push) Successful in -1m53s
Build / Pack and Push NuGet Packages (dns-server) (push) Successful in -1m58s
Build / Build Binary (linux-amd64) (pull_request) Successful in -34s
Build / Build Binary (linux-arm64) (pull_request) Successful in -45s
Build / Build Binary (macos-amd64) (pull_request) Successful in -39s
Build / Build Binary (macos-arm64) (pull_request) Successful in -46s
Build / Build Binary (windows-amd64) (pull_request) Successful in -1m3s
Build / Smoke Test the Windows Binary (pull_request) Successful in 17s
Build / Build Binary (macos-amd64) (push) Successful in -22s
Build / Build Binary (macos-arm64) (push) Successful in -16s
Build / Smoke Test the Windows Binary (push) Successful in 15s
Build / Build Binary (linux-amd64) (push) Successful in -1m4s
Build / Build Binary (linux-arm64) (push) Successful in -27s
Build / Build Binary (windows-amd64) (push) Successful in -48s
Build / Build Arch Linux Packages (pull_request) Successful in -2m0s
Build / Build and Push Image (pull_request) Successful in -2m5s
Build / Build and Test Deb and RPM Packages (pull_request) Successful in 1m36s
Build / Build Arch Linux Packages (push) Successful in -2m12s
Build / Build and Push Image (push) Successful in -2m29s
Build / Build and Test Deb and RPM Packages (push) Successful in 16s
Build / Publish Release (pull_request) Successful in -2m32s
Build / Pipeline (pull_request) Successful in 0s
Build / Publish Release (push) Successful in -2m29s
Build / Pipeline (push) Successful in 0s
0fb90bf8bc
Closes #367
Refs #8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T33E3pmQvqkTriyQUMNUTK
claude merged commit da6560ca1f into develop 2026-11-12 00:37:11 -05:00
claude deleted branch feature/367-relay-abort-on-windows 2026-11-12 00:37:11 -05:00
Sign in to join this conversation.
No reviewers
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lantea-one/ninlil!368
No description provided.