[systemd-commits] 2 commits - src/core src/systemctl

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sun Feb 23 20:56:10 PST 2014


 src/core/dbus-timer.c     |    4 ++--
 src/systemctl/systemctl.c |   42 +++++++++++++++++++++++++++---------------
 2 files changed, 29 insertions(+), 17 deletions(-)

New commits:
commit f5080e738512f92564e272d5dcbb357a1eceaa18
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Mon Feb 24 01:42:24 2014 +0100

    systemctl: move next elapse calculation to its own function

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index c5ca8dc..34d7079 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -908,6 +908,31 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
         return 0;
 }
 
+static usec_t calc_next_elapse(dual_timestamp *nw, dual_timestamp *next) {
+        usec_t next_elapse;
+
+        assert(nw);
+        assert(next);
+
+        if (next->monotonic != (usec_t) -1 && next->monotonic > 0) {
+                usec_t converted;
+
+                if (next->monotonic > nw->monotonic)
+                        converted = nw->realtime + (next->monotonic - nw->monotonic);
+                else
+                        converted = nw->realtime - (nw->monotonic - next->monotonic);
+
+                if (next->realtime != (usec_t) -1 && next->realtime > 0)
+                        next_elapse = MIN(converted, next->realtime);
+                else
+                        next_elapse = converted;
+
+        } else
+                next_elapse = next->realtime;
+
+        return next_elapse;
+}
+
 static int list_timers(sd_bus *bus, char **args) {
 
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
@@ -944,26 +969,13 @@ static int list_timers(sd_bus *bus, char **args) {
                 if (r < 0)
                         goto cleanup;
 
-                if (next.monotonic != (usec_t) -1 && next.monotonic > 0) {
-                        usec_t converted;
-
-                        if (next.monotonic > nw.monotonic)
-                                converted = nw.realtime + (next.monotonic - nw.monotonic);
-                        else
-                                converted = nw.realtime - (nw.monotonic - next.monotonic);
-
-                        if (next.realtime != (usec_t) -1 && next.realtime > 0)
-                                m = MIN(converted, next.realtime);
-                        else
-                                m = converted;
-                } else
-                        m = next.realtime;
-
                 if (!GREEDY_REALLOC(timer_infos, size, c+1)) {
                         r = log_oom();
                         goto cleanup;
                 }
 
+                m = calc_next_elapse(&nw, &next);
+
                 timer_infos[c++] = (struct timer_info) {
                         .id = u->id,
                         .next_elapse = m,

commit 454f7158c6cecd18555c5e7dd556e3d544301b52
Author: Djalal Harouni <tixxdz at opendz.org>
Date:   Mon Feb 24 01:42:23 2014 +0100

    dbus-timer: fix bus_timer_vtable to have the correct times
    
    next_elapse_monotonic() should map to the "NextElapseUSecMonotonic"
    property and next_elapse_realtime() to "NextElapseUSecRealtime" one.
    
    This makes "systemctl list-timers" compute and show the correct times.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=75272

diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index 277a45c..9d54b94 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -140,8 +140,8 @@ const sd_bus_vtable bus_timer_vtable[] = {
         SD_BUS_PROPERTY("Unit", "s", property_get_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_PROPERTY("TimersMonotonic", "a(stt)", property_get_monotonic_timers, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
         SD_BUS_PROPERTY("TimersCalendar", "a(sst)", property_get_calendar_timers, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
-        SD_BUS_PROPERTY("NextElapseUSecRealtime", "t", bus_property_get_usec, offsetof(Timer, next_elapse_monotonic), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
-        SD_BUS_PROPERTY("NextElapseUSecMonotonic", "t", bus_property_get_usec, offsetof(Timer, next_elapse_realtime), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("NextElapseUSecRealtime", "t", bus_property_get_usec, offsetof(Timer, next_elapse_realtime), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
+        SD_BUS_PROPERTY("NextElapseUSecMonotonic", "t", bus_property_get_usec, offsetof(Timer, next_elapse_monotonic), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Timer, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
         SD_BUS_PROPERTY("AccuracyUSec", "t", bus_property_get_usec, offsetof(Timer, accuracy_usec), SD_BUS_VTABLE_PROPERTY_CONST),
         SD_BUS_VTABLE_END



More information about the systemd-commits mailing list