]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: log error when source cannot be added
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 4 May 2021 09:08:59 +0000 (11:08 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 5 May 2021 10:41:23 +0000 (12:41 +0200)
Log an error message when adding of a source fails, e.g. due to the new
limit on number of sources, or when the same address is specified
multiple times.

conf.c

diff --git a/conf.c b/conf.c
index 1f3506159042226bed9b70f99c2b02e29b14e73c..ce2ff0005ee3cd5e97d8875fdd088c1ed4c8cc9a 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1793,6 +1793,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);
+
         /* Mark the source as not present */
         source->params.name[0] = '\0';
       }
@@ -1864,7 +1866,8 @@ CNF_AddInitSources(void)
     ntp_addr.port = cps_source.port;
     cps_source.params.iburst = 1;
 
-    NSR_AddSource(&ntp_addr, NTP_SERVER, &cps_source.params, NULL);
+    if (NSR_AddSource(&ntp_addr, NTP_SERVER, &cps_source.params, NULL) != NSR_Success)
+      LOG(LOGS_ERR, "Could not add source %s", UTI_IPToString(&ntp_addr.ip_addr));
   }
 
   ARR_SetSize(init_sources, 0);
@@ -1877,11 +1880,16 @@ CNF_AddSources(void)
 {
   NTP_Source *source;
   unsigned int i;
+  NSR_Status s;
 
   for (i = 0; i < ARR_GetSize(ntp_sources); i++) {
     source = (NTP_Source *)ARR_GetElement(ntp_sources, i);
-    NSR_AddSourceByName(source->params.name, source->params.port,
-                        source->pool, source->type, &source->params.params, NULL);
+
+    s = NSR_AddSourceByName(source->params.name, source->params.port, source->pool,
+                            source->type, &source->params.params, NULL);
+    if (s != NSR_Success && s != NSR_UnresolvedName)
+      LOG(LOGS_ERR, "Could not add source %s", source->params.name);
+
     Free(source->params.name);
   }