aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix/posix_resolv_gai.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-06 14:45:53 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-06 14:45:53 -0700
commit3da27f7c9c1077f285f53b1e80a1befffe104770 (patch)
treedad07400dced42b061d036c9dd86aaf501592dfc /src/platform/posix/posix_resolv_gai.c
parent82c70435ec9be9c607de4fbd62d4de9ae7d7c081 (diff)
downloadnng-3da27f7c9c1077f285f53b1e80a1befffe104770.tar.gz
nng-3da27f7c9c1077f285f53b1e80a1befffe104770.tar.bz2
nng-3da27f7c9c1077f285f53b1e80a1befffe104770.zip
Fixes for async resolver, plus a test suite for it.
Diffstat (limited to 'src/platform/posix/posix_resolv_gai.c')
-rw-r--r--src/platform/posix/posix_resolv_gai.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index 2b2a8436..82febf6e 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -167,7 +167,7 @@ nni_posix_resolv_task(void *arg)
}
}
// If the only results were not IPv4 or IPv6...
- if (aio->a_addrs == 0) {
+ if (aio->a_naddrs == 0) {
rv = NNG_EADDRINVAL;
break;
}
@@ -231,6 +231,9 @@ nni_posix_resolv_ip(const char *host, const char *serv, int passive,
nni_posix_resolv_item *item;
int rv;
+ if ((aio->a_naddrs != 0) && (aio->a_addrs != NULL)) {
+ NNI_FREE_STRUCTS(aio->a_addrs, aio->a_naddrs);
+ }
if ((item = NNI_ALLOC_STRUCT(item)) == NULL) {
nni_aio_finish(aio, NNG_ENOMEM, 0);
return;
@@ -254,6 +257,7 @@ nni_posix_resolv_ip(const char *host, const char *serv, int passive,
item->name = host;
item->serv = serv;
item->proto = proto;
+ item->aio = aio;
nni_mtx_lock(&nni_posix_resolv_mtx);
// If we were stopped, we're done...
@@ -272,7 +276,7 @@ nni_posix_resolv_ip(const char *host, const char *serv, int passive,
void
-nni_plat_resolv_tcp(const char *host, const char *serv, int family,
+nni_plat_tcp_resolv(const char *host, const char *serv, int family,
int passive, nni_aio *aio)
{
nni_posix_resolv_ip(host, serv, passive, family, IPPROTO_TCP, aio);
@@ -280,7 +284,7 @@ nni_plat_resolv_tcp(const char *host, const char *serv, int family,
int
-nni_posix_resolv_init(void)
+nni_posix_resolv_sysinit(void)
{
int rv;
@@ -296,7 +300,7 @@ nni_posix_resolv_init(void)
void
-nni_posix_resolv_fini(void)
+nni_posix_resolv_sysfini(void)
{
if (nni_posix_resolv_tq != NULL) {
nni_taskq_fini(nni_posix_resolv_tq);