Don't cycle DNS servers while cycling DNS record types.

Motivation:

Each server should be checked for every record type. Currently, if there
are only two configured servers and the first is down, it is impossible
to query for IPv4 addresses because the second server is only ever
queried for type AAAA.

Modifications:

Do not cycle DNS servers while cycling DNS record types (A and AAAA)

Result:

Name resolution is less fragile when the number of available DNS servers
is 2.
This commit is contained in:
Anuraag Agrawal 2015-12-07 17:06:57 +09:00 committed by Trustin Lee
parent 43ebbc3fa0
commit a3bdd8c948

View File

@ -100,6 +100,7 @@ abstract class DnsNameResolverContext<T> {
}
void resolve() {
InetSocketAddress nameServerAddrToTry = nameServerAddrs.next();
for (InternetProtocolFamily f: resolveAddressTypes) {
final DnsRecordType type;
switch (f) {
@ -113,7 +114,7 @@ abstract class DnsNameResolverContext<T> {
throw new Error();
}
query(nameServerAddrs.next(), new DefaultDnsQuestion(hostname, type));
query(nameServerAddrToTry, new DefaultDnsQuestion(hostname, type));
}
}