aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-29 00:06:42 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-29 00:06:42 -0800
commitb5462f65ffa1737df7385c0955527749b77629bd (patch)
tree625d76d18e2ed54058a5da7bf8f674ac3079532a /src/platform/posix
parenta1bc59aaeff1537f06a856f9ecfa23e9924cfad8 (diff)
downloadnng-b5462f65ffa1737df7385c0955527749b77629bd.tar.gz
nng-b5462f65ffa1737df7385c0955527749b77629bd.tar.bz2
nng-b5462f65ffa1737df7385c0955527749b77629bd.zip
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.)
Diffstat (limited to 'src/platform/posix')
-rw-r--r--src/platform/posix/posix_resolv_gai.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index f3f69f9f..9090107b 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -238,7 +238,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;
@@ -248,16 +248,12 @@ resolv_worker(void *index)
if (rv != 0) {
rv = posix_gai_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;
@@ -271,10 +267,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;
}