conf: save source status in sourcedir reload
Save the NSR status when adding a source from a sourcedir and don't hide sources that failed the addition by clearing their name.
This commit is contained in:
parent
8ba2da52df
commit
916ed70c4a
1 changed files with 9 additions and 7 deletions
16
conf.c
16
conf.c
|
@ -294,6 +294,7 @@ typedef struct {
|
||||||
NTP_Source_Type type;
|
NTP_Source_Type type;
|
||||||
int pool;
|
int pool;
|
||||||
CPS_NTP_Source params;
|
CPS_NTP_Source params;
|
||||||
|
NSR_Status status;
|
||||||
uint32_t conf_id;
|
uint32_t conf_id;
|
||||||
} NTP_Source;
|
} NTP_Source;
|
||||||
|
|
||||||
|
@ -834,6 +835,7 @@ parse_source(char *line, char *type, int fatal)
|
||||||
}
|
}
|
||||||
|
|
||||||
source.params.name = Strdup(source.params.name);
|
source.params.name = Strdup(source.params.name);
|
||||||
|
source.status = NSR_NoSuchSource;
|
||||||
source.conf_id = 0;
|
source.conf_id = 0;
|
||||||
|
|
||||||
ARR_AppendElement(ntp_sources, &source);
|
ARR_AppendElement(ntp_sources, &source);
|
||||||
|
@ -1735,33 +1737,33 @@ reload_source_dirs(void)
|
||||||
d = i < prev_size ? -1 : 1;
|
d = i < prev_size ? -1 : 1;
|
||||||
|
|
||||||
/* Remove missing sources before adding others to avoid conflicts */
|
/* Remove missing sources before adding others to avoid conflicts */
|
||||||
if (pass == 0 && d < 0 && prev_sources[i].params.name[0] != '\0') {
|
if (pass == 0 && d < 0 && prev_sources[i].status == NSR_Success) {
|
||||||
NSR_RemoveSourcesById(prev_sources[i].conf_id);
|
NSR_RemoveSourcesById(prev_sources[i].conf_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add new sources */
|
/* Add new sources and sources that could not be added before */
|
||||||
if (pass == 1 && d > 0) {
|
if (pass == 1 && (d > 0 || (d == 0 && prev_sources[i].status != NSR_Success))) {
|
||||||
source = &new_sources[j];
|
source = &new_sources[j];
|
||||||
s = NSR_AddSourceByName(source->params.name, source->params.family, source->params.port,
|
s = NSR_AddSourceByName(source->params.name, source->params.family, source->params.port,
|
||||||
source->pool, source->type, &source->params.params,
|
source->pool, source->type, &source->params.params,
|
||||||
&source->conf_id);
|
&source->conf_id);
|
||||||
|
source->status = s;
|
||||||
|
|
||||||
if (s == NSR_UnresolvedName) {
|
if (s == NSR_UnresolvedName) {
|
||||||
unresolved++;
|
unresolved++;
|
||||||
} else if (s != NSR_Success) {
|
} else if (s != NSR_Success) {
|
||||||
LOG(LOGS_ERR, "Could not add source %s : %s",
|
LOG(LOGS_ERR, "Could not add source %s : %s",
|
||||||
source->params.name, NSR_StatusToString(s));
|
source->params.name, NSR_StatusToString(s));
|
||||||
|
|
||||||
/* Mark the source as not present */
|
|
||||||
source->params.name[0] = '\0';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep unchanged sources */
|
/* Keep unchanged sources */
|
||||||
if (pass == 1 && d == 0)
|
if (pass == 1 && d == 0) {
|
||||||
|
new_sources[j].status = prev_sources[i].status;
|
||||||
new_sources[j].conf_id = prev_sources[i].conf_id;
|
new_sources[j].conf_id = prev_sources[i].conf_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOG_UnsetContext(LOGC_SourceFile);
|
LOG_UnsetContext(LOGC_SourceFile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue