From b5462f65ffa1737df7385c0955527749b77629bd Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 29 Dec 2024 00:06:42 -0800 Subject: resolver: add some additional test coverage While here, remove some code paths that do not occur by definition. (For example, if the resolver succeeds, we will definitely have a valid set of addresses, but if it fails, we will definitely not.) --- src/platform/windows/win_resolv.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/platform/windows') diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c index 83da0b56..6701136e 100644 --- a/src/platform/windows/win_resolv.c +++ b/src/platform/windows/win_resolv.c @@ -196,7 +196,7 @@ resolv_worker(void *index) if ((aio = resolv_active[tid]) == NULL) { // no more interest (canceled), so ignore the result // and carry on - if (results != NULL) { + if (rv == 0) { freeaddrinfo(results); } continue; @@ -206,16 +206,12 @@ resolv_worker(void *index) if (rv != 0) { rv = resolv_errno(rv); nni_aio_finish_error(aio, rv); - if (results != NULL) { - freeaddrinfo(results); - } continue; } // We only take the first matching address. Presumably // DNS load balancing is done by the resolver/server. - rv = NNG_EADDRINVAL; for (probe = results; probe != NULL; probe = probe->ai_next) { if (probe->ai_addr->sa_family == AF_INET) { break; @@ -229,10 +225,8 @@ resolv_worker(void *index) if (probe == NULL) { // no match - nni_aio_finish_error(aio, rv); - if (results != NULL) { - freeaddrinfo(results); - } + nni_aio_finish_error(aio, NNG_EADDRINVAL); + freeaddrinfo(results); continue; } -- cgit v1.2.3-70-g09d2