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/tcp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/core/tcp.c') 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 -- cgit v1.2.3-70-g09d2