conf: improve log message for failed additions in sources reload
Describe the error status in the log message when adding a source from sourcedir failed.
This commit is contained in:
parent
37deee7140
commit
aa8196328c
5 changed files with 37 additions and 1 deletions
3
conf.c
3
conf.c
|
@ -1734,7 +1734,8 @@ reload_source_dirs(void)
|
|||
if (s == NSR_UnresolvedName) {
|
||||
unresolved++;
|
||||
} else if (s != NSR_Success) {
|
||||
LOG(LOGS_ERR, "Could not add source %s", source->params.name);
|
||||
LOG(LOGS_ERR, "Could not add source %s : %s",
|
||||
source->params.name, NSR_StatusToString(s));
|
||||
|
||||
/* Mark the source as not present */
|
||||
source->params.name[0] = '\0';
|
||||
|
|
|
@ -844,6 +844,31 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
const char *
|
||||
NSR_StatusToString(NSR_Status status)
|
||||
{
|
||||
switch (status) {
|
||||
case NSR_Success:
|
||||
return "Success";
|
||||
case NSR_NoSuchSource:
|
||||
return "No such source";
|
||||
case NSR_AlreadyInUse:
|
||||
return "Already in use";
|
||||
case NSR_TooManySources:
|
||||
return "Too many sources";
|
||||
case NSR_InvalidAF:
|
||||
return "Invalid address";
|
||||
case NSR_InvalidName:
|
||||
return "Invalid name";
|
||||
case NSR_UnresolvedName:
|
||||
return "Unresolved name";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
NSR_SetSourceResolvingEndHandler(NSR_SourceResolvingEndHandler handler)
|
||||
{
|
||||
|
|
|
@ -60,6 +60,8 @@ extern NSR_Status NSR_AddSource(NTP_Remote_Address *remote_addr, NTP_Source_Type
|
|||
extern NSR_Status NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
|
||||
SourceParameters *params, uint32_t *conf_id);
|
||||
|
||||
extern const char *NSR_StatusToString(NSR_Status status);
|
||||
|
||||
/* Function type for handlers to be called back when an attempt
|
||||
* (possibly unsuccessful) to resolve unresolved sources ends */
|
||||
typedef void (*NSR_SourceResolvingEndHandler)(void);
|
||||
|
|
6
stubs.c
6
stubs.c
|
@ -207,6 +207,12 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type,
|
|||
return NSR_TooManySources;
|
||||
}
|
||||
|
||||
const char *
|
||||
NSR_StatusToString(NSR_Status status)
|
||||
{
|
||||
return "NTP not supported";
|
||||
}
|
||||
|
||||
NSR_Status
|
||||
NSR_RemoveSource(IPAddr *address)
|
||||
{
|
||||
|
|
|
@ -88,6 +88,8 @@ update_random_address(NTP_Remote_Address *addr, int rand_bits)
|
|||
TEST_CHECK(status == NSR_Success || status == NSR_AlreadyInUse);
|
||||
}
|
||||
|
||||
TEST_CHECK(strlen(NSR_StatusToString(status)) > 0);
|
||||
|
||||
return status == NSR_Success;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue