From 5ad4f5ef5f5db6dd6dd0d8c495902f9c16112013 Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Thu, 31 Aug 2023 02:20:45 +0800 Subject: [PATCH] fix(forward): usage of PollFuture --- rd-std/src/builtin/forward.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rd-std/src/builtin/forward.rs b/rd-std/src/builtin/forward.rs index 96ceeb1b..82a3a278 100644 --- a/rd-std/src/builtin/forward.rs +++ b/rd-std/src/builtin/forward.rs @@ -173,6 +173,7 @@ struct UdpSource { target: Address, resolve_interval: Option, resolve_future: PollFuture>, + resolved: Option, resolve_at: Option, } @@ -187,6 +188,7 @@ impl UdpSource { resolve_net: resolve_net.clone(), listen_udp: udp, resolve_future: PollFuture::new(resolve_target(resolve_net, target.clone())), + resolved: None, resolve_at: None, target, resolve_interval, @@ -211,7 +213,14 @@ impl RawUdpSource for UdpSource { } } - let to = ready!(self.resolve_future.poll(cx))?; + let to = match self.resolved { + Some(to) => to, + None => { + let to = ready!(self.resolve_future.poll(cx))?; + self.resolved = Some(to); + to + } + }; if self.resolve_at.is_none() { self.resolve_at = Some(Instant::now());