mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
netdb/dns: add support of send timeout
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user