mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 01:27:11 +03:00
unit: don't override timestamps due to state changes when deserializing
This commit is contained in:
parent
39366bacda
commit
bdbf995180
35
src/unit.c
35
src/unit.c
@ -1101,7 +1101,6 @@ void unit_trigger_on_failure(Unit *u) {
|
||||
}
|
||||
|
||||
void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_success) {
|
||||
dual_timestamp ts;
|
||||
bool unexpected;
|
||||
|
||||
assert(u);
|
||||
@ -1114,6 +1113,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
||||
* behaviour here. For example: if a mount point is remounted
|
||||
* this function will be called too! */
|
||||
|
||||
if (u->meta.manager->n_deserializing <= 0) {
|
||||
dual_timestamp ts;
|
||||
|
||||
dual_timestamp_get(&ts);
|
||||
|
||||
if (UNIT_IS_INACTIVE_OR_FAILED(os) && !UNIT_IS_INACTIVE_OR_FAILED(ns))
|
||||
@ -1126,11 +1128,12 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
||||
else if (UNIT_IS_ACTIVE_OR_RELOADING(os) && !UNIT_IS_ACTIVE_OR_RELOADING(ns))
|
||||
u->meta.active_exit_timestamp = ts;
|
||||
|
||||
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
|
||||
cgroup_bonding_trim_list(u->meta.cgroup_bondings, true);
|
||||
|
||||
timer_unit_notify(u, ns);
|
||||
path_unit_notify(u, ns);
|
||||
}
|
||||
|
||||
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
|
||||
cgroup_bonding_trim_list(u->meta.cgroup_bondings, true);
|
||||
|
||||
if (u->meta.job) {
|
||||
unexpected = false;
|
||||
@ -1198,26 +1201,31 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
||||
} else
|
||||
unexpected = true;
|
||||
|
||||
/* If this state change happened without being requested by a
|
||||
* job, then let's retroactively start or stop
|
||||
* dependencies. We skip that step when deserializing, since
|
||||
* we don't want to create any additional jobs just because
|
||||
* something is already activated. */
|
||||
if (u->meta.manager->n_deserializing <= 0) {
|
||||
|
||||
if (unexpected && u->meta.manager->n_deserializing <= 0) {
|
||||
/* If this state change happened without being
|
||||
* requested by a job, then let's retroactively start
|
||||
* or stop dependencies. We skip that step when
|
||||
* deserializing, since we don't want to create any
|
||||
* additional jobs just because something is already
|
||||
* activated. */
|
||||
|
||||
if (unexpected) {
|
||||
if (UNIT_IS_INACTIVE_OR_FAILED(os) && UNIT_IS_ACTIVE_OR_ACTIVATING(ns))
|
||||
retroactively_start_dependencies(u);
|
||||
else if (UNIT_IS_ACTIVE_OR_ACTIVATING(os) && UNIT_IS_INACTIVE_OR_DEACTIVATING(ns))
|
||||
retroactively_stop_dependencies(u);
|
||||
}
|
||||
|
||||
if (ns != os && ns == UNIT_FAILED && u->meta.manager->n_deserializing <= 0) {
|
||||
if (ns != os && ns == UNIT_FAILED) {
|
||||
log_notice("Unit %s entered failed state.", u->meta.id);
|
||||
unit_trigger_on_failure(u);
|
||||
}
|
||||
|
||||
|
||||
/* Some names are special */
|
||||
if (UNIT_IS_ACTIVE_OR_RELOADING(ns)) {
|
||||
|
||||
if (unit_has_name(u, SPECIAL_DBUS_SERVICE))
|
||||
/* The bus just might have become available,
|
||||
* hence try to connect to it, if we aren't
|
||||
@ -1259,14 +1267,15 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
|
||||
}
|
||||
}
|
||||
|
||||
manager_recheck_syslog(u->meta.manager);
|
||||
}
|
||||
|
||||
/* Maybe we finished startup and are now ready for being
|
||||
* stopped because unneeded? */
|
||||
unit_check_unneeded(u);
|
||||
|
||||
unit_add_to_dbus_queue(u);
|
||||
unit_add_to_gc_queue(u);
|
||||
|
||||
manager_recheck_syslog(u->meta.manager);
|
||||
}
|
||||
|
||||
int unit_watch_fd(Unit *u, int fd, uint32_t events, Watch *w) {
|
||||
|
Loading…
Reference in New Issue
Block a user