]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "Fix issue with system time set back (#24131)" 25083/head
authorLuca Boccassi <bluca@debian.org>
Thu, 20 Oct 2022 13:01:09 +0000 (14:01 +0100)
committerLuca Boccassi <bluca@debian.org>
Thu, 20 Oct 2022 13:01:09 +0000 (14:01 +0100)
This fix unfortunately introduced a much worse regression that
is affecting many users, so let's revert it for now and rework
it in the next release.

This reverts commit 5ded3917a161d87984d74d70b5eb2a254e54b44e.

Fixes https://github.com/systemd/systemd/issues/24984

src/core/timer.c
test/units/testsuite-53.sh

index cfc20fb613e552596264a84c8d55b3c4cf375398..8bd430b931d1d540b8518d4c618391f88f7d09ff 100644 (file)
@@ -394,18 +394,19 @@ static void timer_enter_waiting(Timer *t, bool time_change) {
                 if (v->base == TIMER_CALENDAR) {
                         usec_t b, rebased;
 
-                        /* Update last_trigger to 'now' in case the system time changes, so that
-                         * next_elapse is not stuck with a future date. */
-                        if (time_change)
-                                b = ts.realtime;
-                        /* If we know the last time this was triggered, schedule the job based relative
-                         * to that. If we don't, just start from the activation time. */
-                        else if (t->last_trigger.realtime > 0)
+                        /* If we know the last time this was
+                         * triggered, schedule the job based relative
+                         * to that. If we don't, just start from
+                         * the activation time. */
+
+                        if (t->last_trigger.realtime > 0)
                                 b = t->last_trigger.realtime;
-                        else if (state_translation_table[t->state] == UNIT_ACTIVE)
-                                b = UNIT(t)->inactive_exit_timestamp.realtime;
-                        else
-                                b = ts.realtime;
+                        else {
+                                if (state_translation_table[t->state] == UNIT_ACTIVE)
+                                        b = UNIT(t)->inactive_exit_timestamp.realtime;
+                                else
+                                        b = ts.realtime;
+                        }
 
                         r = calendar_spec_next_usec(v->calendar_spec, b, &v->next_elapse);
                         if (r < 0)
index f12b7379fdb2720b073ded257371a7b008641a38..84cd66129d007e40c166bf8b772e26161a5a7b14 100755 (executable)
@@ -5,44 +5,27 @@ set -o pipefail
 
 : >/failed
 
-# Run a timer for every 15 minutes before setting the current time
-systemd-run --unit test-timer-1 --on-calendar "*:0/15:0" true
-
 # Reset host date to current time, 3 days in the past.
 date -s "-3 days"
 
-# Run another timer for every 15 minutes, after setting the time
-systemd-run --unit test-timer-2 --on-calendar "*:0/15:0" true
-
-next_elapsed_t1=$(systemctl show test-timer-1.timer -p NextElapseUSecRealtime --value)
-next_elapsed_t1=$(date -d "${next_elapsed_t1}" +%s)
-now=$(date +%s)
-time_delta_t1=$((next_elapsed_t1 - now))
+# Run a timer for every 15 minutes.
+systemd-run --unit test-timer --on-calendar "*:0/15:0" true
 
-next_elapsed_t2=$(systemctl show test-timer-2.timer -p NextElapseUSecRealtime --value)
-next_elapsed_t2=$(date -d "${next_elapsed_t2}" +%s)
+next_elapsed=$(systemctl show test-timer.timer -p NextElapseUSecRealtime --value)
+next_elapsed=$(date -d "${next_elapsed}" +%s)
 now=$(date +%s)
-time_delta_t2=$((next_elapsed_t2 - now))
-
-# Check that the timer will elapse in less than 20 minutes.
-((0 < time_delta_t1 && time_delta_t1 < 1200)) || {
-    echo 'Timer elapse outside of the expected 20 minute window.'
-    echo "  next_elapsed_t1=${next_elapsed_t1}"
-    echo "  now=${now}"
-    echo "  time_delta_t1=${time_delta_t1}"
-    echo ''
-} >>/failed_t1
+time_delta=$((next_elapsed - now))
 
 # Check that the timer will elapse in less than 20 minutes.
-((0 < time_delta_t2 && time_delta_t2 < 1200)) || {
+((0 < time_delta && time_delta < 1200)) || {
     echo 'Timer elapse outside of the expected 20 minute window.'
-    echo "  next_elapsed_t2=${next_elapsed_t2}"
+    echo "  next_elapsed=${next_elapsed}"
     echo "  now=${now}"
-    echo "  time_delta_t2=${time_delta_t2}"
+    echo "  time_delta=${time_delta}"
     echo ''
-} >>/failed_t2
+} >>/failed
 
-if test ! -s /failed_t1 && test ! -s /failed_t2; then
-    rm -f /failed_t*
+if test ! -s /failed ; then
+    rm -f /failed
     touch /testok
 fi