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 <g...@greenie.muc.de> --- src/openvpn/socket.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 13ed981..f9ee5ad 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", -- 2.4.0