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/core/url.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/core/url.c') diff --git a/src/core/url.c b/src/core/url.c index 1b39f809..48c79037 100644 --- a/src/core/url.c +++ b/src/core/url.c @@ -678,10 +678,11 @@ nng_url_clone(nng_url **dstp, const nng_url *src) int nni_url_to_address(nng_sockaddr *sa, const nng_url *url) { - int af; - nni_aio aio; - const char *h; - int rv; + int af; + nni_aio aio; + const char *h; + int rv; + nni_resolv_item ri; // This assumes the scheme is one that uses TCP/IP addresses. @@ -700,7 +701,13 @@ nni_url_to_address(nng_sockaddr *sa, const nng_url *url) h = NULL; } - nni_resolv_ip(h, url->u_port, af, true, sa, &aio); + memset(&ri, 0, sizeof(ri)); + ri.ri_family = af; + ri.ri_passive = true; + ri.ri_host = h; + ri.ri_port = url->u_port; + ri.ri_sa = sa; + nni_resolv(&ri, &aio); nni_aio_wait(&aio); rv = nni_aio_result(&aio); nni_aio_fini(&aio); -- cgit v1.2.3-70-g09d2