Skip to content

DnsOverHttps Fixups: event sequencing, resolvePublicAddresses, IPv6 first#9553

Merged
swankjesse merged 6 commits into
masterfrom
jwilson.0716.new_tests
Jul 17, 2026
Merged

DnsOverHttps Fixups: event sequencing, resolvePublicAddresses, IPv6 first#9553
swankjesse merged 6 commits into
masterfrom
jwilson.0716.new_tests

Conversation

@swankjesse

Copy link
Copy Markdown
Collaborator

The biggest change here is we’re now requesting TYPE_AAAA (IPv6) records first in all DnsOverHttps calls. This should be a negligible behavior change for most applications as the two calls can execute in parallel. The order only really matters when there’s a limit on the total concurrency against the DNS service. (This is the case for our tests, which only permit 1 call at a a time.)

Fix some bugs in how events are delivered to the callback. Always deliver events on OkHttp’s dispatcher thread. This includes cancel events and resolvePublicAddress validation. Otherwise it’s surprising if the callback is sometimes invoked by the thread calling enqueue().

}

override fun isCanceled() = state.get() is State.Canceled
override fun isCanceled() = calls.all { it.isCanceled() }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think given RealCall, this works in practice.

But based on the interface of Call, it could be racy?

  /** Cancels the request, if possible. Requests that are already complete cannot be canceled. */
  fun cancel()

So if some are completed, and you are using some other Call impl, which I know is unlikely, it may not be correct when one call already completed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh, yeah I totally missed that. Good analysis. I added a test case that handles RealCall, but it’s arguably a bug that RealCall allows you to cancel something that’s already completed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I added a volatile to track whether this is canceled, similar to how RealCall does it. I previously had a Canceled state (and LookupDnsCall still does!), so I might refactor to do that also.

@yschimke yschimke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question about cancellation

@swankjesse
swankjesse merged commit e14cdaa into master Jul 17, 2026
2 checks passed
@swankjesse
swankjesse deleted the jwilson.0716.new_tests branch July 17, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants