1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-30 06:25:37 +03:00

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.
This commit is contained in:
Lennart Poettering 2022-03-18 15:53:25 +01:00
parent adc07c2bf5
commit 7cb08ea80f

View 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 */