Stopping the DNSCrypt UDP listener logs no receive warning #22

Closed
opened 2026-10-31 12:41:51 -04:00 by claude · 0 comments
Owner
  • Draft: REL-14
  • Priority: low (a spurious Warning on some stops)
  • Agent: protocol-coder
  • Depends on: none
  • Decisions: none

Why

RP-1 saw the UDP listener log a shutdown cancellation (SocketException 125) as a Warning. The
plain listener was fixed in 7648beb0: UdpDnsListener.StopAsync clears IsListening before it
closes the sockets and the receive loop treats a SocketException as the stop when IsListening
is false (src/dotnet/src/Ninlil.Dns.Protocol.Plain/UdpDnsListener.cs:155-165,218-223).
DnsCryptUdpListener has the same order (close at :249, token cancelled later by
base.StopAsync) but only checks the token (src/dotnet/src/Ninlil.Dns.Protocol.DnsCrypt/DnsCryptUdpListener.cs:189-195),
so the same race logs "Error receiving a DNSCrypt UDP datagram." on a stop. The DHCP, TFTP and
RA listeners cancel the token before closing, so they are not affected.

What changes

DnsCryptUdpListener: the same IsListening rule as UdpDnsListener, with the same comment.

Acceptance

  • A guard test like StopAsync_WhileReceiveLoopsArePending_LogsNoWarning (the plain
    listener's) in src/dotnet/tests/Ninlil.Dns.Protocol.DnsCrypt.Tests. The race may not fail
    reliably: say so, and give the evidence used (for example 50 query-then-stop cycles with a
    count of warnings before and after).
  • DnsCrypt.Tests by path.

Source

release-prep.md:21 (RP-1 nit), release-prep.md:120 (W5 fix and its mechanism).

- **Draft:** REL-14 - **Priority:** low (a spurious Warning on some stops) - **Agent:** protocol-coder - **Depends on:** none - **Decisions:** none ### Why RP-1 saw the UDP listener log a shutdown cancellation (SocketException 125) as a Warning. The plain listener was fixed in 7648beb0: `UdpDnsListener.StopAsync` clears `IsListening` before it closes the sockets and the receive loop treats a SocketException as the stop when `IsListening` is false (`src/dotnet/src/Ninlil.Dns.Protocol.Plain/UdpDnsListener.cs:155-165,218-223`). `DnsCryptUdpListener` has the same order (close at `:249`, token cancelled later by `base.StopAsync`) but only checks the token (`src/dotnet/src/Ninlil.Dns.Protocol.DnsCrypt/DnsCryptUdpListener.cs:189-195`), so the same race logs "Error receiving a DNSCrypt UDP datagram." on a stop. The DHCP, TFTP and RA listeners cancel the token before closing, so they are not affected. ### What changes `DnsCryptUdpListener`: the same `IsListening` rule as `UdpDnsListener`, with the same comment. ### Acceptance - [ ] A guard test like `StopAsync_WhileReceiveLoopsArePending_LogsNoWarning` (the plain listener's) in `src/dotnet/tests/Ninlil.Dns.Protocol.DnsCrypt.Tests`. The race may not fail reliably: say so, and give the evidence used (for example 50 query-then-stop cycles with a count of warnings before and after). - [ ] DnsCrypt.Tests by path. ### Source `release-prep.md:21` (RP-1 nit), `release-prep.md:120` (W5 fix and its mechanism).
Sign in to join this conversation.
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#22
No description provided.