ASSI via devel writes:
> is… intriguing.  If you follow the code through the function, ts_min in
> the log should always be ts_prev+sys_fuzz; these two values can't be
> identical or differ by any other value, ts_min must strictly be greater
> than ts_prev by sys_fuzz.  I notice that there is always a DNS operation
> logged at the same time when I get these errors, so I am pretty sure
> this is related to the DNS thread.  This would also explain why a server
> that has many clients would see many more such errors.

While I have not yet identified the code path that is involved (likely
something in NTS, I think), you might want to try the following monkey
patch:

Subject: [PATCH] Wrap get_systime in critical section to serialize
 timestamping among multiple threads

---
 libntp/systime.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libntp/systime.c b/libntp/systime.c
index 8efea6cfe..5e87aee15 100644
--- a/libntp/systime.c
+++ b/libntp/systime.c
@@ -6,6 +6,8 @@
  */
 #include "config.h"
 
+#include <pthread.h>
+
 #include "ntp.h"
 #include "ntp_syslog.h"
 #include "ntp_stdlib.h"
@@ -209,14 +211,30 @@ normalize_time(
 /*
  * get_systime - return system time in NTP timestamp format.
  */
+static pthread_mutex_t systime_lock = PTHREAD_MUTEX_INITIALIZER;
+
 void
 get_systime(
 	l_fp *now		/* system time */
 	)
 {
+	struct timespec ts_lock = { 0, 0 };
+	struct timespec ts_delta = { 0, 0 };
 	struct timespec ts;	/* seconds and nanoseconds */
+	if (pthread_mutex_trylock(&systime_lock)) {
+	  get_ostime(&ts_lock);
+	  pthread_mutex_lock(&systime_lock);
+	}
 	get_ostime(&ts);
+	ts_delta = ts;
 	normalize_time(ts, sys_fuzz > 0.0 ? ntp_random() : 0, now);
+	pthread_mutex_unlock(&systime_lock);
+	if (ts_lock.tv_nsec != 0 || ts_lock.tv_sec != 0) {
+	  ts_delta = sub_tspec(ts_delta, ts_lock);
+	  msyslog(LOG_WARNING,
+		  "CLOCK: we were blocked for %ld.%09ld s while waiting for another thread",
+		  (long)ts_delta.tv_sec, ts_delta.tv_nsec);
+	}
 }
 
 
-- 
2.24.0

Let me know if makes a difference on your system.  The error crops up
too sparingly on mine to really tell if it helps or not.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada
_______________________________________________
devel mailing list
devel@ntpsec.org
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to