You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/04/27 08:20:21 UTC
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #892: Netdb multiple dns servers
xiaoxiang781216 commented on a change in pull request #892:
URL: https://github.com/apache/incubator-nuttx/pull/892#discussion_r415608827
##########
File path: libs/libc/netdb/lib_dnsaddserver.c
##########
@@ -198,10 +198,24 @@ int dns_add_nameserver(FAR const struct sockaddr *addr, socklen_t addrlen)
{
FAR uint16_t *pport;
size_t copylen;
+ int nservers;
+ int idx;
DEBUGASSERT(addr != NULL);
- /* Copy the new server IP address into our private global data structure */
+ /* Get the index of the next free nameserver slot. */
+
+ dns_semtake();
+ if (g_dns_nservers == CONFIG_NETDB_DNSSERVER_NAMESERVERS)
Review comment:
> Perhaps, but note that the resolv.conf version of the function appends the new nameserver at the end of the file. It should be changed to match for consistency. I would leave that to some future PR.
>
If so, it is better to append the new server to the end of list and iterate through the server backward.
> I think the most common use case is to get DNS1, DNS2,... IPs from operator and then add entire list by first calling dns_default_nameserver() and then add the DNS1, DNS2, DNS3... and maybe add some generic fallback server like Google's 8.8.8.8 as _last_ in case operator's preferred servers are down.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org