From 7cb08ea80f66dbaadfa0350cb09adf155449bcc6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Mar 2022 15:53:25 +0100 Subject: [PATCH] timesyncd: move stuff that is not about setting the clock out of manager_adjust_clock() 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 | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 302f09125f6..3ab08a0fd60 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -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 */