Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnsdist: Only call getsockname() once per incoming DoH connection #11851

Merged

Conversation

rgacogne
Copy link
Member

Short description

The current code is calling h2o_socket_getpeername() and h2o_socket_getsockname() once per DoH query, and while the former is cheap because h2o caches the result for us, the latter is actually expensive, so this code caches both values so that we only retrieve
them once per DoH connection.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

The current code is calling h2o_socket_getpeername() and
h2o_socket_getsockname() once per DoH _query_, and while the former
is cheap because h2o caches the result for us, the latter is actually
expensive, so this code caches both values so that we only retrieve
them once per DoH connection.
Copy link
Member

@Habbie Habbie left a comment

Choose a reason for hiding this comment

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

Very nice, I like the defer until the first query, doesn't get much more efficient than that!

@rgacogne rgacogne merged commit 94d1e9b into PowerDNS:master Aug 16, 2022
@rgacogne rgacogne deleted the ddist-doh-only-call-getsockname-once branch August 16, 2022 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants