X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftimedate%2Ftimedated.c;h=909575786a128ed89f1d5e398a1673295e134b3d;hb=15411c0cb1192799b37ec8f25d6f30e8d7292fc6;hp=88d57e9d5432da609c5b989ed460aec6c500a304;hpb=2479df30946dd327b0745ec5f9b7d3542b9538e3;p=elogind.git diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 88d57e9d5..909575786 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -43,7 +43,7 @@ #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n" static BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map timedated_errors[] = { - SD_BUS_ERROR_MAP("org.freedesktop.timedate1.NoNTPSupport", ENOTSUP), + SD_BUS_ERROR_MAP("org.freedesktop.timedate1.NoNTPSupport", EOPNOTSUPP), SD_BUS_ERROR_MAP_END }; @@ -551,6 +551,9 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu if (c->use_ntp) return sd_bus_error_setf(error, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, "Automatic time synchronization is enabled"); + /* this only gets used if dbus does not provide a timestamp */ + start = now(CLOCK_MONOTONIC); + r = sd_bus_message_read(m, "xbb", &utc, &relative, &interactive); if (r < 0) return r; @@ -590,10 +593,11 @@ static int method_set_time(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu /* adjust ts for time spent in program */ r = sd_bus_message_get_monotonic_usec(m, &start); + /* when sd_bus_message_get_monotonic_usec() returns -ENODATA it does not modify &start */ if (r < 0 && r != -ENODATA) return r; - if (r >= 0) - timespec_store(&ts, timespec_load(&ts) + (now(CLOCK_MONOTONIC) - start)); + + timespec_store(&ts, timespec_load(&ts) + (now(CLOCK_MONOTONIC) - start)); /* Set system clock */ if (clock_settime(CLOCK_REALTIME, &ts) < 0) {