aboutsummaryrefslogtreecommitdiff
path: root/src/core/tcp.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/tcp.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/tcp.c')
-rw-r--r--src/core/tcp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/tcp.c b/src/core/tcp.c
index fd1c7e96..b0ed75fb 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -31,6 +31,7 @@ typedef struct {
nni_aio conaio; // platform connection aio
nni_list conaios;
nni_mtx mtx;
+ nni_resolv_item resolv;
} tcp_dialer;
static void
@@ -57,7 +58,14 @@ tcp_dial_start_next(tcp_dialer *d)
if (nni_list_empty(&d->conaios)) {
return;
}
- nni_resolv_ip(d->host, d->port, d->af, false, &d->sa, &d->resaio);
+ memset(&d->resolv, 0, sizeof(d->resolv));
+ d->resolv.ri_family = d->af;
+ d->resolv.ri_passive = false;
+ d->resolv.ri_host = d->host;
+ d->resolv.ri_port = d->port;
+ d->resolv.ri_sa = &d->sa;
+
+ nni_resolv(&d->resolv, &d->resaio);
}
static void