]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
conf: don't repeat error message when adding sourcedir source
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 6 Aug 2024 11:05:26 +0000 (13:05 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 7 Aug 2024 07:48:24 +0000 (09:48 +0200)
When a source from a configured sourcedir cannot be added (e.g. it is a
duplicate of another source), log the error message only on the first
attempt adding the source, until the source is removed and added to a
sourcedir again.

This avoids spamming of the system log with error messages if the
reload sources command is called frequently (e.g. from a DHCP renewal
networking script).

conf.c
test/system/008-confload

diff --git a/conf.c b/conf.c
index f18dfa90adc7ec0ff71239e4a268af866df636b2..858099fcde938f8f01d4e8788a3ef06269ac91d2 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -1751,7 +1751,7 @@ reload_source_dirs(void)
 
         if (s == NSR_UnresolvedName) {
           unresolved++;
-        } else if (s != NSR_Success) {
+        } else if (s != NSR_Success && (d > 0 || s != prev_sources[i].status)) {
           LOG(LOGS_ERR, "Could not add source %s : %s",
               source->params.name, NSR_StatusToString(s));
         }
index b978c190e177f291d3696e07b5d4c440433a91f6..b107d70984c7ed4fde078a301f0056ce875641cb 100755 (executable)
@@ -102,7 +102,7 @@ check_chronyc_output "^[^=]*
 run_chronyc "reload sources" || test_fail
 
 stop_chronyd || test_fail
-check_chronyd_message_count "Could not add source.*\.5\.5.*in use" 3 3 || test_fail
-check_chronyd_message_count "Could not add source" 3 3 || test_fail
+check_chronyd_message_count "Could not add source.*\.5\.5.*in use" 1 1 || test_fail
+check_chronyd_message_count "Could not add source" 1 1 || test_fail
 
 test_pass