aboutsummaryrefslogtreecommitdiff
path: root/src/core/url.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-28 23:29:35 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-28 23:29:35 -0800
commitd574649899a29ce7eb96485c0a4c606f14f87011 (patch)
tree0d6282c98fc458a4c24cc0b9f0f442bb2b958da3 /src/core/url.c
parent945dbef5e8eb060654aec33851937f1e3325913b (diff)
downloadnng-d574649899a29ce7eb96485c0a4c606f14f87011.tar.gz
nng-d574649899a29ce7eb96485c0a4c606f14f87011.tar.bz2
nng-d574649899a29ce7eb96485c0a4c606f14f87011.zip
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.
Diffstat (limited to 'src/core/url.c')
-rw-r--r--src/core/url.c17
1 files changed, 12 insertions, 5 deletions
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);