chiark / gitweb /
libsystemd-network: move network-utils from src/shared
[elogind.git] / src / timedate / timedate-sntp.c
index 36b2a1a1a5627c57151cc8cc5007f38d6f491009..cb0bf794f1d1641ea6940bf24b97394e09bf0a3f 100644 (file)
@@ -347,14 +347,12 @@ static int sntp_adjust_clock(SNTPContext *sntp, double offset, int leap_sec) {
          * syncs the system time periodically to the hardware clock.
          */
         if (offset < NTP_MAX_ADJUST && offset > -NTP_MAX_ADJUST) {
-                int constant;
-
-                constant = log2i(sntp->poll_interval_usec / USEC_PER_SEC) - 6;
-
-                tmx.modes |= ADJ_STATUS | ADJ_OFFSET | ADJ_TIMECONST;
+                tmx.modes |= ADJ_STATUS | ADJ_OFFSET | ADJ_TIMECONST | ADJ_MAXERROR | ADJ_ESTERROR;
                 tmx.status = STA_PLL;
                 tmx.offset = offset * 1000 * 1000;
-                tmx.constant = constant;
+                tmx.constant = log2i(sntp->poll_interval_usec / USEC_PER_SEC) - 6;
+                tmx.maxerror = 0;
+                tmx.esterror = 0;
                 log_debug("  adjust (slew): %+f sec\n", (double)tmx.offset / USEC_PER_SEC);
         } else {
                 tmx.modes = ADJ_SETOFFSET;
@@ -444,7 +442,7 @@ static void sntp_adjust_poll(SNTPContext *sntp, double offset, bool spike) {
         }
 
         /* set to minimal poll interval */
-        if (fabs(offset) > NTP_ACCURACY_SEC) {
+        if (!spike && fabs(offset) > NTP_ACCURACY_SEC) {
                 sntp->poll_interval_usec = NTP_POLL_INTERVAL_MIN_SEC * USEC_PER_SEC;
                 return;
         }