From: Gert Doering Date: Sun, 31 May 2015 13:59:09 +0000 (+0200) Subject: Move res_init() call to inner openvpn_getaddrinfo() loop X-Git-Tag: v2.4_alpha1~285 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=288a819af7d3a6fab9e0b69ae8dbaac74b36307b;p=thirdparty%2Fopenvpn.git Move res_init() call to inner openvpn_getaddrinfo() loop 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 Acked-by: Arne Schwabe Message-Id: <1433080749-6892-1-git-send-email-gert@greenie.muc.de> URL: http://article.gmane.org/gmane.network.openvpn.devel/9763 --- diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 4f1139d75..7f889b1fe 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -314,10 +314,6 @@ openvpn_getaddrinfo (unsigned int flags, ASSERT(res); -#ifndef WIN32 - res_init (); -#endif - ASSERT (hostname || servname); ASSERT (!(flags & GETADDR_HOST_ORDER)); @@ -394,6 +390,9 @@ openvpn_getaddrinfo (unsigned int flags, */ while (true) { +#ifndef WIN32 + res_init (); +#endif /* try hostname lookup */ hints.ai_flags &= ~AI_NUMERICHOST; dmsg (D_SOCKET_DEBUG, "GETADDRINFO flags=0x%04x ai_family=%d ai_socktype=%d",