mirror of https://github.com/ARMmbed/mbed-os.git
DNS: Rework DNS query
Don't ask multiple DNS servers in case of successful connection, even if the response is negative. Make sure the return value is correct.pull/2982/head
parent
f5fb485dcd
commit
3d09b196b7
|
@ -217,7 +217,7 @@ static int nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
|
||||||
return NSAPI_ERROR_NO_MEMORY;
|
return NSAPI_ERROR_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = NSAPI_ERROR_OK;
|
int result = NSAPI_ERROR_DNS_FAILURE;
|
||||||
|
|
||||||
// check against each dns server
|
// check against each dns server
|
||||||
for (unsigned i = 0; i < DNS_SERVERS_SIZE; i++) {
|
for (unsigned i = 0; i < DNS_SERVERS_SIZE; i++) {
|
||||||
|
@ -243,11 +243,12 @@ static int nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *response = packet;
|
const uint8_t *response = packet;
|
||||||
if (!dns_scan_response(&response, addr, addr_count)) {
|
if (dns_scan_response(&response, addr, addr_count) > 0) {
|
||||||
result = NSAPI_ERROR_DNS_FAILURE;
|
result = NSAPI_ERROR_OK;
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The DNS response is final, no need to check other servers */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up packet
|
// clean up packet
|
||||||
|
|
Loading…
Reference in New Issue