mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:35:06 -05:00
Add delayed name resolving for servers and peers
Resolving is retried in increasing intervals (maximum is one hour) until it succeeds or fails with a non-temporary error. Unresolved sources are included in the activity report as offline sources and the online command can be used to retry it immediately. This could be improved by resolving in a separate thread/process to avoid blocking.
This commit is contained in:
12
cmdparse.c
12
cmdparse.c
@@ -33,6 +33,7 @@
|
||||
#include "sysincl.h"
|
||||
|
||||
#include "cmdparse.h"
|
||||
#include "memory.h"
|
||||
#include "nameserv.h"
|
||||
|
||||
#define MAXLEN 2047
|
||||
@@ -66,6 +67,10 @@ CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src)
|
||||
s = DNS_Name2IPAddress(hostname, &src->ip_addr);
|
||||
if (s == DNS_Success) {
|
||||
ok = 1;
|
||||
src->name = NULL;
|
||||
} else if (s == DNS_TryAgain) {
|
||||
ok = 1;
|
||||
src->ip_addr.family = IPADDR_UNSPEC;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +165,13 @@ CPS_ParseNTPSourceAdd(const char *line, CPS_NTP_Source *src)
|
||||
} while (!done);
|
||||
}
|
||||
|
||||
if (ok && src->ip_addr.family == IPADDR_UNSPEC) {
|
||||
n = strlen(hostname);
|
||||
src->name = MallocArray(char, n + 1);
|
||||
strncpy(src->name, hostname, n);
|
||||
src->name[n] = '\0';
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user