netdb/dns: fix dns wrong response ID error
In every dns query, we use the new socket to avoid receiving last response ID Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
parent
9b5746cb5f
commit
693898d566
@ -586,13 +586,7 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
int next = 0;
|
||||
int retries;
|
||||
int ret;
|
||||
|
||||
int sd = dns_bind(addr->sa_family);
|
||||
if (sd < 0)
|
||||
{
|
||||
query->result = sd;
|
||||
return 0;
|
||||
}
|
||||
int sd;
|
||||
|
||||
/* Loop while receive timeout errors occur and there are remaining
|
||||
* retries.
|
||||
@ -603,6 +597,13 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
/* Send the IPv6 query */
|
||||
|
||||
sd = dns_bind(addr->sa_family);
|
||||
if (sd < 0)
|
||||
{
|
||||
query->result = sd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_AAAA, &qinfo);
|
||||
@ -627,11 +628,20 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
query->result = ret;
|
||||
}
|
||||
}
|
||||
|
||||
close(sd);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
/* Send the IPv4 query */
|
||||
|
||||
sd = dns_bind(addr->sa_family);
|
||||
if (sd < 0)
|
||||
{
|
||||
query->result = sd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_A, &qinfo);
|
||||
@ -656,6 +666,8 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
query->result = ret;
|
||||
}
|
||||
}
|
||||
|
||||
close(sd);
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
if (next > 0)
|
||||
@ -670,7 +682,6 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
*/
|
||||
|
||||
*query->naddr = next;
|
||||
close(sd);
|
||||
return 1;
|
||||
}
|
||||
else if (query->result != -EAGAIN)
|
||||
@ -679,7 +690,6 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
||||
}
|
||||
}
|
||||
|
||||
close(sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user