]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
timesyncd: move stuff that is not about setting the clock out of manager_adjust_clock()
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Mar 2022 14:53:25 +0000 (15:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Mar 2022 22:53:31 +0000 (23:53 +0100)
Let's make sure manager_adjust_clock() is purely about setting the
clock, and nothing else.

Let's clean up logging this way. manager_adjust_clock() now won#t log
about errors, but the caller can safely do that, and do with the right
log message string.

src/timesync/timesyncd-manager.c

index 302f09125f6e128fcd97e3a9dedeeda8e27dc0c8..3ab08a0fd60c9a44d1e67030156e21f8f2a2e93e 100644 (file)
@@ -245,7 +245,6 @@ static int manager_clock_watch_setup(Manager *m) {
 
 static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
         struct timex tmx;
-        int r;
 
         assert(m);
 
@@ -299,13 +298,6 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
         if (clock_adjtime(CLOCK_REALTIME, &tmx) < 0)
                 return -errno;
 
-        r = manager_save_time_and_rearm(m);
-        if (r < 0)
-                return r;
-
-        /* If touch fails, there isn't much we can do. Maybe it'll work next time. */
-        (void) touch("/run/systemd/timesync/synchronized");
-
         m->drift_freq = tmx.freq;
 
         log_debug("  status       : %04i %s\n"
@@ -580,6 +572,13 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
                 r = manager_adjust_clock(m, offset, leap_sec);
                 if (r < 0)
                         log_error_errno(r, "Failed to call clock_adjtime(): %m");
+
+                r = manager_save_time_and_rearm(m);
+                if (r < 0)
+                        return r;
+
+                /* If touch fails, there isn't much we can do. Maybe it'll work next time. */
+                (void) touch("/run/systemd/timesync/synchronized");
         }
 
         /* Save NTP response */