[GH-ISSUE #430] ResolverFuture::lookup_ip() is not lazy (enough) #486

Closed
opened 2026-03-15 22:45:17 +03:00 by kerem · 3 comments
Owner

Originally created by @briansmith on GitHub (Apr 26, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/430

Futures shouldn't do any work until polled, so that they can support code patterns like this (taken from real code):

        // Construct the future, expecting nothing will happen yet.
        let lookup = self.resolver.lookup_ip(&name.0);

        // Do something that needs to be done before the lookup
        // is initiated.
        let f = Timeout::new(delay, &self.executor)
            .expect("Timeout::new() won't fail")
            .then(move |_| {
                // OK, now actually start doing the lookup work.
                lookup
            });

        // Wrap the future in a Box, giving it a lifetime that is (potentially)
        // longer than `self`. Because of this lifetime issue, we can't call
        // `self.resolver.lookup_ip(&name.0);` inside the closure above.
        return Box::new(f);

ResolverFuture::lookup_ip() appears to be doing a lot of work and so it doesn't seem to support this code pattern well.

Originally created by @briansmith on GitHub (Apr 26, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/430 Futures shouldn't do any work until polled, so that they can support code patterns like this (taken from real code): ```rust // Construct the future, expecting nothing will happen yet. let lookup = self.resolver.lookup_ip(&name.0); // Do something that needs to be done before the lookup // is initiated. let f = Timeout::new(delay, &self.executor) .expect("Timeout::new() won't fail") .then(move |_| { // OK, now actually start doing the lookup work. lookup }); // Wrap the future in a Box, giving it a lifetime that is (potentially) // longer than `self`. Because of this lifetime issue, we can't call // `self.resolver.lookup_ip(&name.0);` inside the closure above. return Box::new(f); ``` `ResolverFuture::lookup_ip()` appears to be doing a lot of work and so it doesn't seem to support this code pattern well.
kerem 2026-03-15 22:45:17 +03:00
Author
Owner

@hawkw commented on GitHub (May 18, 2018):

I'd like to start looking into this issue --- @bluejekyll, are you actively working on this and/or will it interfere with any other ongoing work?

<!-- gh-comment-id:390309295 --> @hawkw commented on GitHub (May 18, 2018): I'd like to start looking into this issue --- @bluejekyll, are you actively working on this and/or will it interfere with any other ongoing work?
Author
Owner

@bluejekyll commented on GitHub (May 18, 2018):

I'm not aware of this effecting any other work, and no, I haven't started working on it. I will warn you, I don't know yet how deep this goes... but it could unravel quickly, especially in how timeouts are tracked.

<!-- gh-comment-id:390330904 --> @bluejekyll commented on GitHub (May 18, 2018): I'm not aware of this effecting any other work, and no, I haven't started working on it. I will warn you, I don't know yet how deep this goes... but it could unravel quickly, especially in how timeouts are tracked.
Author
Owner

@hawkw commented on GitHub (May 18, 2018):

Well, I have a preliminary branch making this change. It's rather ugly, so probably needs some more work on my end before it's ready for a PR...

<!-- gh-comment-id:390359600 --> @hawkw commented on GitHub (May 18, 2018): Well, I have [a preliminary branch](https://github.com/bluejekyll/trust-dns/compare/master...hawkw:eliza/lazier-resolver-future?expand=1) making this change. It's rather ugly, so probably needs some more work on my end before it's ready for a PR...
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#486
No description provided.