From d574649899a29ce7eb96485c0a4c606f14f87011 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 28 Dec 2024 23:29:35 -0800 Subject: resolver: use explicit resolver item provided by caller This avoids the need to perform multiple allocations for dialing, eliminating additional potential failures. Cancellation is also made simpler and more perfectly robust. --- src/sp/transport/udp/udp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/sp') diff --git a/src/sp/transport/udp/udp.c b/src/sp/transport/udp/udp.c index ac3d3f1a..fee142e3 100644 --- a/src/sp/transport/udp/udp.c +++ b/src/sp/transport/udp/udp.c @@ -220,6 +220,7 @@ struct udp_ep { udp_txring tx_ring; nni_time next_wake; nni_aio_completions complq; + nni_resolv_item resolv; nni_stat_item st_rcv_max; nni_stat_item st_rcv_reorder; @@ -1529,9 +1530,14 @@ udp_ep_connect(void *arg, nni_aio *aio) // lookup the IP address + memset(&ep->resolv, 0, sizeof(ep->resolv)); + ep->resolv.ri_family = ep->af; + ep->resolv.ri_host = ep->url->u_hostname; + ep->resolv.ri_port = ep->url->u_port; + ep->resolv.ri_passive = false; + ep->resolv.ri_sa = &ep->peer_sa; nni_aio_set_timeout(&ep->resaio, NNI_SECOND * 5); - nni_resolv_ip(ep->url->u_hostname, ep->url->u_port, ep->af, false, - &ep->peer_sa, &ep->resaio); + nni_resolv(&ep->resolv, &ep->resaio); // wake up for retries nni_aio_abort(&ep->timeaio, NNG_EINTR); -- cgit v1.2.3-70-g09d2