]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Move res_init() call to inner openvpn_getaddrinfo() loop
authorGert Doering <gert@greenie.muc.de>
Sun, 31 May 2015 13:59:09 +0000 (15:59 +0200)
committerGert Doering <gert@greenie.muc.de>
Tue, 2 Jun 2015 07:39:05 +0000 (09:39 +0200)
A non-working nameserver in /etc/resolv.conf could lead to endless
loops inside openvpn_getaddrinfo(), because many systems will only
pick up changes to resolv.conf if res_init() is called again.

To reproduce, run openvpn with --resolv-retry infinite (2.3) or
--resolv-retry "a high number" (master) on a BSD system.  Linux
glibc seems to stat() resolv.conf on calls to getaddrinfo() and
pick up changes automatically.

Trac #523

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1433080749-6892-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9763
(cherry picked from commit 288a819af7d3a6fab9e0b69ae8dbaac74b36307b)

src/openvpn/socket.c

index a604e31d146599ad53705c362840db3df9d395c5..0424c0ba4f4d3123799ebce7d907dc287b31fab6 100644 (file)
@@ -137,10 +137,6 @@ openvpn_getaddrinfo (unsigned int flags,
 
   ASSERT(res);
 
-#ifndef WIN32
-  res_init ();
-#endif
-
   if (!hostname)
     hostname = "::";
 
@@ -197,6 +193,9 @@ openvpn_getaddrinfo (unsigned int flags,
        */
       while (true)
         {
+#ifndef WIN32
+         res_init ();
+#endif
           /* try hostname lookup */
           hints.ai_flags = 0;
           dmsg (D_SOCKET_DEBUG, "GETADDRINFO flags=0x%04x ai_family=%d ai_socktype=%d",