From 1e29f1fa6327636a598cafe5f1704d8cfdfe3c67 Mon Sep 17 00:00:00 2001 From: Nick Peng Date: Mon, 30 Jan 2023 23:26:08 +0800 Subject: [PATCH] dns_client: add retry when bootstrap from system DNS. --- src/dns_client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dns_client.c b/src/dns_client.c index d30a448..7f7ae88 100644 --- a/src/dns_client.c +++ b/src/dns_client.c @@ -3765,9 +3765,13 @@ static void _dns_client_add_pending_servers(void) if (dns_client_has_bootstrap_dns == 0) { if (_dns_client_add_pendings(pending, pending->host) != 0) { pthread_mutex_unlock(&pending_server_mutex); - tlog(TLOG_ERROR, "add pending DNS server %s failed", pending->host); - exit(1); - return; + tlog(TLOG_INFO, "add pending DNS server %s from resolv.conf failed, retry %d...", pending->host, + pending->retry_cnt - 1); + if (pending->retry_cnt - 1 > DNS_PENDING_SERVER_RETRY) { + tlog(TLOG_WARN, "add pending DNS server %s from resolv.conf failed, exit...", pending->host); + exit(1); + } + continue; } _dns_client_server_pending_release(pending);