Unfortunately, glibc assumes that /etc/resolv.conf is a static file that
never changes. Even on servers, /etc/resolv.conf might be a dynamically
generated file, and we never know when it changes. So just call
res_init() every time, so glibc uses up-to-date nameserver information.
#include <netinet/if_ether.h>
#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#ifdef STATUS
+#undef STATUS
+#endif
+#endif
+
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+
#endif /* __TINC_SYSTEM_H__ */
#include "subnet.h"
#include "xalloc.h"
-#ifdef HAVE_ARPA_NAMESER_H
-#include <arpa/nameser.h>
-#endif
-
-#ifdef HAVE_RESOLV_H
-#include <resolv.h>
-#endif
-
bool do_purge = false;
volatile bool running = false;
#ifdef HAVE_PSELECT
avl_node_t *node;
logger(LOG_INFO, "Flushing event queue");
expire_events();
-#if HAVE_DECL_RES_INIT
- res_init();
-#endif
for(node = connection_tree->head; node; node = node->next) {
connection_t *c = node->data;
if(c->status.active)
hint.ai_protocol = IPPROTO_TCP;
hint.ai_flags = AI_PASSIVE;
+#ifdef HAVE_DECL_RES_INIT
+ // ensure glibc reloads /etc/resolv.conf.
+ res_init();
+#endif
err = getaddrinfo(address && *address ? address : NULL, port, &hint, &ai);
free(address);
hint.ai_family = addressfamily;
hint.ai_socktype = socktype;
+#ifdef HAVE_DECL_RES_INIT
+ // ensure glibc reloads /etc/resolv.conf.
+ res_init();
+#endif
err = getaddrinfo(address, service, &hint, &ai);
if(err) {