mirror of
https://github.com/safing/portmaster.git
synced 2026-12-04 09:38:21 +00:00
13a86a43cc
Related ticket: #2104 On shutdown the NameServer module stopped its listeners with dns.Server.Shutdown, which waits without limit for all in-flight request handlers to return. A handler can be stuck in an upstream connect that the kernel never completes: a connection pended by a firewall driver cannot be cancelled. In #2104 the pending driver was our own kext, because the Interception module stops before Resolver and NameServer, so DoT dials issued in that window had nobody left to answer their verdict. The module Stop() has no time bound, so the whole shutdown stalled and the Windows service stayed in "Stopping" until reboot. - nameserver: stop listeners with ShutdownContext and a 10 second timeout. Reading from the listener socket stops immediately; only the wait for running handlers is bounded. Handlers still running afterwards are cancelled and waited for by the module manager as before. - resolver: do not dial a new upstream connection once the instance has started shutting down. The instance context is cancelled before any module stops, so this closes the window in which a dial could be pended after interception is gone. Existing pooled connections are still used. The resolver instance interface gains ShuttingDown() for this. The kext-side part (do not pend new connections after the Shutdown command) is a separate change that needs a signed driver release.