Skip to content

Commit

Permalink
Retry according to number of desired retries,
Browse files Browse the repository at this point in the history
no matter the error type.
  • Loading branch information
tonjo committed Aug 1, 2023
1 parent 729242a commit 43e278e
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,11 @@ static inline bool parse_endpoint(struct sockaddr *endpoint, const char *value)
ret = getaddrinfo(begin, end, &hints, &resolved);
if (!ret)
break;
/* The set of return codes that are "permanent failures". All other possibilities are potentially transient.
*
* This is according to https://sourceware.org/glibc/wiki/NameResolver which states:
* "From the perspective of the application that calls getaddrinfo() it perhaps
* doesn't matter that much since EAI_FAIL, EAI_NONAME and EAI_NODATA are all
* permanent failure codes and the causes are all permanent failures in the
* sense that there is no point in retrying later."
*
* So this is what we do, except FreeBSD removed EAI_NODATA some time ago, so that's conditional.
*/
if (ret == EAI_NONAME || ret == EAI_FAIL ||
#ifdef EAI_NODATA
ret == EAI_NODATA ||
#endif
(retries >= 0 && !retries--)) {
/*
Treating all errors as possibly temporary.
Armbian has been reported to not distinguish between a temporary and a permanent DNS resolution error
*/
if (retries >= 0 && !retries--) {
free(mutable);
fprintf(stderr, "%s: `%s'\n", ret == EAI_SYSTEM ? strerror(errno) : gai_strerror(ret), value);
return false;
Expand Down

0 comments on commit 43e278e

Please sign in to comment.