mirror of
https://github.com/systemd/systemd.git
synced 2024-12-18 06:33:36 +08:00
Revert "Fix issue with system time set back (#24131)"
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 5ded3917a1
.
Fixes https://github.com/systemd/systemd/issues/24984
This commit is contained in:
parent
40c05a3459
commit
0bf1d0ff04
@ -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)
|
||||
|
@ -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
|
||||
# Run a timer for every 15 minutes.
|
||||
systemd-run --unit test-timer --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)
|
||||
next_elapsed=$(systemctl show test-timer.timer -p NextElapseUSecRealtime --value)
|
||||
next_elapsed=$(date -d "${next_elapsed}" +%s)
|
||||
now=$(date +%s)
|
||||
time_delta_t1=$((next_elapsed_t1 - now))
|
||||
|
||||
next_elapsed_t2=$(systemctl show test-timer-2.timer -p NextElapseUSecRealtime --value)
|
||||
next_elapsed_t2=$(date -d "${next_elapsed_t2}" +%s)
|
||||
now=$(date +%s)
|
||||
time_delta_t2=$((next_elapsed_t2 - now))
|
||||
time_delta=$((next_elapsed - now))
|
||||
|
||||
# Check that the timer will elapse in less than 20 minutes.
|
||||
((0 < time_delta_t1 && time_delta_t1 < 1200)) || {
|
||||
((0 < time_delta && time_delta < 1200)) || {
|
||||
echo 'Timer elapse outside of the expected 20 minute window.'
|
||||
echo " next_elapsed_t1=${next_elapsed_t1}"
|
||||
echo " next_elapsed=${next_elapsed}"
|
||||
echo " now=${now}"
|
||||
echo " time_delta_t1=${time_delta_t1}"
|
||||
echo " time_delta=${time_delta}"
|
||||
echo ''
|
||||
} >>/failed_t1
|
||||
} >>/failed
|
||||
|
||||
# Check that the timer will elapse in less than 20 minutes.
|
||||
((0 < time_delta_t2 && time_delta_t2 < 1200)) || {
|
||||
echo 'Timer elapse outside of the expected 20 minute window.'
|
||||
echo " next_elapsed_t2=${next_elapsed_t2}"
|
||||
echo " now=${now}"
|
||||
echo " time_delta_t2=${time_delta_t2}"
|
||||
echo ''
|
||||
} >>/failed_t2
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user