Gate DoH retries and keep-alives on screen state - #747
Open
kasnder wants to merge 1 commit into
Open
Conversation
Screen-off DoH queries used to run the full retry loop and leave an idle TLS keep-alive socket behind after every lookup. During doze a retry is a second radio wakeup for a query that is already failing, and an idle pooled socket can be reset by the server mid-doze, waking the radio. While the screen is off: skip retries, and evict the connection pool after each query so nothing idle survives. Screen-on restores retries and normal pooling. The response cache is intentionally preserved - it is most valuable at night, when queries repeat against a dozing device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screen-off DoH queries used to run the full retry loop and leave an idle TLS keep-alive socket behind after every lookup. During doze a retry is a second radio wakeup for a query that is already failing, and an idle pooled socket can be reset by the server mid-doze, waking the radio (the known screen-off DoH battery issue from AGENTS.md).
What changes
DnsOverHttpsClient: newsetScreenOff()policy. While the screen is off,resolve()skips retries (MAX_RETRIES -> 0) and evicts the connection pool after each query so nothing idle survives. Screen-on restores retries and normal pooling.DnsProxyServer:onScreenOff()replaced withonScreenStateChanged(interactive);start()syncs the policy so a reload mid-doze doesn't inherit screen-on behaviour.ServiceSinkhole: the interactive-state receiver now pushes both screen transitions to the proxy.Tests
DnsOverHttpsClientTest:resolveDoesNotRetryWhenScreenOffasserts a 503 gives up after one request (vs three with the screen on). All 16 tests pass.