bool found_monotonic = false, found_realtime = false;
bool leave_around = false;
triple_timestamp ts;
- dual_timestamp dts;
TimerValue *v;
Unit *trigger;
int r;
continue;
if (v->base == TIMER_CALENDAR) {
- usec_t b;
+ usec_t b, rebased;
/* If we know the last time this was
* triggered, schedule the job based relative
if (r < 0)
continue;
- /* To make the delay due to RandomizedDelaySec= work even at boot,
- * if the scheduled time has already passed, set the time when systemd
- * first started as the scheduled time. */
- dual_timestamp_from_monotonic(&dts, UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic);
- if (v->next_elapse < dts.realtime)
- v->next_elapse = dts.realtime;
+ /* To make the delay due to RandomizedDelaySec= work even at boot, if the scheduled
+ * time has already passed, set the time when systemd first started as the scheduled
+ * time. Note that we base this on the monotonic timestamp of the boot, not the
+ * realtime one, since the wallclock might have been off during boot. */
+ rebased = map_clock_usec(UNIT(t)->manager->timestamps[MANAGER_TIMESTAMP_USERSPACE].monotonic,
+ CLOCK_MONOTONIC, CLOCK_REALTIME);
+ if (v->next_elapse < rebased)
+ v->next_elapse = rebased;
if (!found_realtime)
t->next_elapse_realtime = v->next_elapse;