ntp: start resolving only from NSR_ResolveSources
Also, use macros to define the minimum and maximum resolving interval.
This commit is contained in:
parent
6ee357d230
commit
9b137b2e37
2 changed files with 10 additions and 8 deletions
|
@ -74,6 +74,10 @@ struct UnresolvedSource {
|
|||
struct UnresolvedSource *next;
|
||||
};
|
||||
|
||||
#define RESOLVE_INTERVAL_UNIT 7
|
||||
#define MIN_RESOLVE_INTERVAL 2
|
||||
#define MAX_RESOLVE_INTERVAL 9
|
||||
|
||||
static struct UnresolvedSource *unresolved_sources = NULL;
|
||||
static int resolving_interval = 0;
|
||||
static SCH_TimeoutID resolving_id;
|
||||
|
@ -273,9 +277,12 @@ name_resolve_handler(DNS_Status status, IPAddr *ip_addr, void *anything)
|
|||
/* This was the last source in the list. If some sources couldn't
|
||||
be resolved, try again in exponentially increasing interval. */
|
||||
if (unresolved_sources) {
|
||||
if (resolving_interval < 9)
|
||||
if (resolving_interval < MIN_RESOLVE_INTERVAL)
|
||||
resolving_interval = MIN_RESOLVE_INTERVAL;
|
||||
else if (resolving_interval < MAX_RESOLVE_INTERVAL)
|
||||
resolving_interval++;
|
||||
resolving_id = SCH_AddTimeoutByDelay(7 * (1 << resolving_interval), resolve_sources, NULL);
|
||||
resolving_id = SCH_AddTimeoutByDelay(RESOLVE_INTERVAL_UNIT *
|
||||
(1 << resolving_interval), resolve_sources, NULL);
|
||||
} else {
|
||||
resolving_interval = 0;
|
||||
}
|
||||
|
@ -326,11 +333,6 @@ NSR_AddUnresolvedSource(char *name, int port, NTP_Source_Type type, SourceParame
|
|||
for (i = &unresolved_sources; *i; i = &(*i)->next)
|
||||
;
|
||||
*i = us;
|
||||
|
||||
if (!resolving_interval) {
|
||||
resolving_interval = 2;
|
||||
resolving_id = SCH_AddTimeoutByDelay(7 * (1 << resolving_interval), resolve_sources, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef void (*NSR_SourceResolvingEndHandler)(void);
|
|||
/* Set the handler, or NULL to disable the notification */
|
||||
extern void NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler);
|
||||
|
||||
/* Procedure to start resolving unresolved sources immediately */
|
||||
/* Procedure to start resolving unresolved sources */
|
||||
extern void NSR_ResolveSources(void);
|
||||
|
||||
/* Procedure to start all sources */
|
||||
|
|
Loading…
Reference in a new issue