syslogd: Retry address lookup forever, never give up
When logging to a remote server, using @fqdn syntax in syslog.conf, syslogd calls getaddrinfo() to resolve the IP address. Older versions of syslogd gave up after 10 retries. We want to retry forever since we may be running in a setup with bad network connection to the DNS server for longer periods of time. This patch only removes the 'give up' mechanism, which unfortunately reused the f_prevcount value, which in turn could cause that value to become -1 and thus trigger an assert(). With this code out of the way, and the type change in the previous commit, the counter can never again be negative. Note: The configurable suspend time before trying again remains at its default of 3 minutes. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
49e168601e
commit
b7d4225ef1
@ -1427,17 +1427,7 @@ void fprintlog_write(struct filed *f, struct iovec *iov, int iovcnt, int flags)
|
||||
logit("Forwarding suspension to %s:%s over, retrying\n", host, serv);
|
||||
err = nslookup(host, serv, &ai);
|
||||
if (err) {
|
||||
logit("Failure resolving %s:%s: %s\n", host, serv, gai_strerror(err));
|
||||
logit("Retries: %d\n", f->f_prevcount);
|
||||
if (--f->f_prevcount < 0) {
|
||||
WARN("Still cannot find %s, giving up: %s",
|
||||
host, gai_strerror(err));
|
||||
f->f_type = F_UNUSED;
|
||||
} else {
|
||||
WARN("Still cannot find %s, will try again later: %s",
|
||||
host, gai_strerror(err));
|
||||
logit("Left retries: %d\n", f->f_prevcount);
|
||||
}
|
||||
WARN("Failure resolving %s:%s: %s", host, serv, gai_strerror(err));
|
||||
} else {
|
||||
NOTE("Found %s, resuming operation.", host);
|
||||
f->f_un.f_forw.f_addr = ai;
|
||||
@ -2464,16 +2454,14 @@ static struct filed *cfline(char *line)
|
||||
|
||||
err = nslookup(p, bp, &ai);
|
||||
if (err) {
|
||||
WARN("Cannot find %s, will try again later: %s", p, gai_strerror(err));
|
||||
/*
|
||||
* The host might be unknown due to an inaccessible
|
||||
* nameserver (perhaps on the same host). We try to
|
||||
* get the ip number later, like FORW_SUSP.
|
||||
*/
|
||||
f->f_type = F_FORW_UNKN;
|
||||
f->f_prevcount = INET_RETRY_MAX;
|
||||
f->f_time = time(NULL);
|
||||
f->f_un.f_forw.f_addr = NULL;
|
||||
WARN("Cannot find %s, will try again later: %s", p, gai_strerror(err));
|
||||
} else {
|
||||
f->f_type = F_FORW;
|
||||
f->f_un.f_forw.f_addr = ai;
|
||||
|
@ -106,7 +106,6 @@
|
||||
#ifndef INET_SUSPEND_TIME
|
||||
#define INET_SUSPEND_TIME 180 /* equal to 3 minutes */
|
||||
#endif
|
||||
#define INET_RETRY_MAX 10 /* maximum of retries for getaddrinfo() */
|
||||
|
||||
#define LIST_DELIMITER ':' /* delimiter between two hosts */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user