[GH-ISSUE #2089] Should async_std_resolver::resolver_from_system_conf be async? #881

Open
opened 2026-03-16 00:44:45 +03:00 by kerem · 1 comment
Owner

Originally created by @thomaseizinger on GitHub (Nov 9, 2023).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2089

The above mentioned function is currently marked async but doesn't use await:

github.com/hickory-dns/hickory-dns@d07455476c/crates/async-std-resolver/src/lib.rs (L141-L143)

When digging deeper, @oblique found out that the underlying file IO with /etc/resolv.conf is using blocking access:

github.com/hickory-dns/hickory-dns@d07455476c/crates/resolver/src/system_conf/unix.rs (L30-L39)

At the moment, this is kind of the worst of both worlds:

  1. We need to deal with a Future in upper layers.
  2. The resulting future doesn't actually use non-blocking IO.

I think a fix in either direction makes sense although I am leaning slightly towards removing async because /etc/resolv.conf is likely very small so the blocking IO shouldn't matter much in practice.

Related: https://github.com/libp2p/rust-libp2p/pull/4808#discussion_r1388674218.

Originally created by @thomaseizinger on GitHub (Nov 9, 2023). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2089 The above mentioned function is currently marked `async` but doesn't use `await`: https://github.com/hickory-dns/hickory-dns/blob/d07455476cfba08a661c09f303af2cfbb8c1a5cc/crates/async-std-resolver/src/lib.rs#L141-L143 When digging deeper, @oblique found out that the underlying file IO with `/etc/resolv.conf` is using blocking access: https://github.com/hickory-dns/hickory-dns/blob/d07455476cfba08a661c09f303af2cfbb8c1a5cc/crates/resolver/src/system_conf/unix.rs#L30-L39 At the moment, this is kind of the worst of both worlds: 1. We need to deal with a `Future` in upper layers. 2. The resulting future doesn't actually use non-blocking IO. I think a fix in either direction makes sense although I am leaning slightly towards removing `async` because `/etc/resolv.conf` is likely very small so the blocking IO shouldn't matter much in practice. Related: https://github.com/libp2p/rust-libp2p/pull/4808#discussion_r1388674218.
Author
Owner

@djc commented on GitHub (Nov 20, 2023):

Makes sense to me to make the method synchronous, thanks for the bug report!

<!-- gh-comment-id:1818783776 --> @djc commented on GitHub (Nov 20, 2023): Makes sense to me to make the method synchronous, thanks for the bug report!
Sign in to join this conversation.
No milestone
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
starred/hickory-dns#881
No description provided.