diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-04-24 03:45:40 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-05-17 18:07:42 +0200 |
commit | 18857075306c39e7a30484dc392ec6baa5d69a92 (patch) | |
tree | 663d86c6c61ff912e73af7635c26bc62d6f0d156 /src/tools | |
parent | compat: remember to call iptunnel_xmit_stats (diff) | |
download | wireguard-monolithic-historical-18857075306c39e7a30484dc392ec6baa5d69a92.tar.xz wireguard-monolithic-historical-18857075306c39e7a30484dc392ec6baa5d69a92.zip |
tools: retry name resolution on temporary failure
This should solve many problems at init time.
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/config.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/config.c b/src/tools/config.c index be15870..c00e91c 100644 --- a/src/tools/config.c +++ b/src/tools/config.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <sys/socket.h> #include <sys/stat.h> #include <errno.h> @@ -189,7 +190,15 @@ static inline bool parse_endpoint(struct sockaddr *endpoint, const char *value) *end = '\0'; ++end; } - ret = getaddrinfo(begin, end, &hints, &resolved); + + for (unsigned int timeout = 1000000; timeout < 90000000; timeout = timeout * 3 / 2) { + ret = getaddrinfo(begin, end, &hints, &resolved); + if (ret != EAI_AGAIN) + break; + fprintf(stderr, "%s: `%s`. Trying again in %.2f seconds...\n", gai_strerror(ret), value, timeout / 1000000.0); + usleep(timeout); + } + if (ret != 0) { free(mutable); fprintf(stderr, "%s: `%s`\n", gai_strerror(ret), value); |