summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_resolven_loop.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-03-17 13:53:52 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-03-17 13:53:52 +0000
commitd62aec3ffabf77655c6bd028cf45213e034522fb (patch)
tree73f5e22595b5738b0a36e29f9819e84ac1d7a2ac /src/libs6dns/s6dns_resolven_loop.c
parent4a04ef3219548a450cf3b7df2cca9f009c027167 (diff)
downloads6-dns-d62aec3ffabf77655c6bd028cf45213e034522fb.tar.xz
bugfix: s6dns_resolve_aaaaa API on double nodata
Diffstat (limited to 'src/libs6dns/s6dns_resolven_loop.c')
-rw-r--r--src/libs6dns/s6dns_resolven_loop.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libs6dns/s6dns_resolven_loop.c b/src/libs6dns/s6dns_resolven_loop.c
index 23b1c36..2cc5da0 100644
--- a/src/libs6dns/s6dns_resolven_loop.c
+++ b/src/libs6dns/s6dns_resolven_loop.c
@@ -15,7 +15,8 @@ int s6dns_resolven_loop (s6dns_engine_t *dt, unsigned int n, unsigned int or, ta
{
iopause_fd x[n] ;
unsigned int count = 0 ;
- for (;;)
+ unsigned int got = 0 ;
+ while (got < n)
{
tain_t localdeadline = *deadline ;
int r ;
@@ -34,19 +35,23 @@ int s6dns_resolven_loop (s6dns_engine_t *dt, unsigned int n, unsigned int or, ta
else if (!r)
{
if (tain_less(deadline, stamp)) return (errno = ETIMEDOUT, -1) ;
- for (i = 0 ; i < n ; i++) if (dt[i].status == EAGAIN)
- if (s6dns_engine_timeout(dt + i, stamp) && (or >= 2)) return i ;
+ for (i = 0 ; i < n ; i++) if (dt[i].status == EAGAIN && s6dns_engine_timeout(dt + i, stamp))
+ {
+ got++ ;
+ if (or >= 2) return i ;
+ }
}
else
{
for (i = 0 ; i < n ; i++) if (dt[i].status == EAGAIN)
{
r = s6dns_engine_event(dt + i, stamp) ;
- if (or)
+ if (r)
{
- if (r && ((r > 0) || (or >= 2))) return i ;
+ got++ ;
+ if (r > 0) count++ ;
+ if (or && (r > 0 || or >= 2)) return i ;
}
- else if (r > 0) count++ ;
}
}
}