netdb/dns: add support of send timeout

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2022-12-14 18:49:22 +08:00
committed by Xiang Xiao
parent 3a50911810
commit 0c21bc4e53
2 changed files with 18 additions and 0 deletions
+7
View File
@@ -121,6 +121,13 @@ config NETDB_DNSCLIENT_RECV_TIMEOUT
This is the timeout value when DNS receives response after
dns_send_query, unit: seconds
config NETDB_DNSCLIENT_SEND_TIMEOUT
int "DNS send timeout"
default NETDB_DNSCLIENT_RECV_TIMEOUT
---help---
This is the timeout value when DNS send request on dns_send_query,
unit: seconds
config NETDB_DNSCLIENT_RETRIES
int "Number of retries for DNS request"
default 3
+11
View File
@@ -83,6 +83,17 @@ int dns_bind(sa_family_t family)
tv.tv_usec = 0;
ret = setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
if (ret >= 0)
{
/* Set up a send timeout */
tv.tv_sec = CONFIG_NETDB_DNSCLIENT_SEND_TIMEOUT;
tv.tv_usec = 0;
ret = setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv,
sizeof(struct timeval));
}
if (ret < 0)
{
ret = -get_errno();