Systemd/src/core
Michal Schmidt e0209d83e7 core: add NOP jobs, job type collapsing
Two of our current job types are special:
JOB_TRY_RESTART, JOB_RELOAD_OR_START.

They differ from other job types by being sensitive to the unit active state.
They perform some action when the unit is active and some other action
otherwise. This raises a question: when exactly should the unit state be
checked to make the decision?

Currently the unit state is checked when the job becomes runnable. It's more
sensible to check the state immediately when the job is added by the user.
When the user types "systemctl try-restart foo.service", he really intends
to restart the service if it's running right now. If it isn't running right
now, the restart is pointless.

Consider the example (from Bugzilla[1]):

sleep.service takes some time to start.
hello.service has After=sleep.service.
Both services get started. Two jobs will appear:
 hello.service/start  waiting
 sleep.service/start  running
Then someone runs "systemctl try-restart hello.service".

Currently the try-restart operation will block and wait for
sleep.service/start to complete.

The correct result is to complete the try-restart operation immediately
with success, because hello.service is not running. The two original
jobs must not be disturbed by this.

To fix this we introduce two new concepts:
- a new job type: JOB_NOP
  A JOB_NOP job does not do anything to the unit. It does not pull in any
  dependencies. It is always immediately runnable. When installed to a unit,
  it sits in a special slot (u->nop_job) where it never conflicts with
  the installed job (u->job) of a different type. It never merges with jobs
  of other types, but it can merge into an already installed JOB_NOP job.

- "collapsing" of job types
  When a job of one of the two special types is added, the state of the unit
  is checked immediately and the job type changes:
  JOB_TRY_RESTART     -> JOB_RESTART or JOB_NOP
  JOB_RELOAD_OR_START -> JOB_RELOAD or JOB_START
  Should a job type JOB_RELOAD_OR_START appear later during job merging, it
  collapses immediately afterwards.
  Collapsing actually makes some things simpler, because there are now fewer
  job types that are allowed in the transaction.

[1] Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=753586
2012-04-25 18:38:27 +02:00
..
.gitignore update .gitignore 2012-04-13 21:58:01 +02:00
automount.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
automount.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
build.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
bus-errors.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
cgroup-attr.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
cgroup-attr.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
cgroup.c logind: remove redundant entries from logind's default controller lists too 2012-04-16 19:15:00 +02:00
cgroup.h logind: remove redundant entries from logind's default controller lists too 2012-04-16 19:15:00 +02:00
condition.c util: fix tty_is_vc_resolve() in a container where /sys/class/tty/console/active is misleading 2012-04-22 01:59:11 +02:00
condition.h unit: introduce ConditionPathIsReadWrite 2012-04-12 12:58:19 +02:00
dbus-automount.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-automount.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-device.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-device.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-execute.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-execute.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-job.c job: serialize jobs properly 2012-04-24 01:54:15 +02:00
dbus-job.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-manager.c manager: drop MountAuto= and SwapAuto= options 2012-04-24 13:53:34 +02:00
dbus-manager.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-mount.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-mount.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-path.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-path.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-service.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-service.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-snapshot.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-snapshot.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-socket.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-socket.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-swap.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-swap.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-target.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-target.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-timer.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-timer.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-unit.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus-unit.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
dbus.c dbus-job: allow multiple bus clients 2012-04-20 17:12:29 +02:00
dbus.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
device.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
device.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
execute.c service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
execute.h service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
fdset.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
fdset.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
hostname-setup.c hostname: if there's already a hostname set when PID 1 is invoked, don't complain 2012-04-22 15:47:38 +02:00
hostname-setup.h hostname-setup: move to core/ 2012-04-12 14:23:17 +02:00
ima-setup.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
ima-setup.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
initreq.h move libsystemd_core.la sources into core/ 2012-04-11 16:03:51 +02:00
job.c core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
job.h core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
kmod-setup.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
kmod-setup.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
load-dropin.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
load-dropin.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
load-fragment-gperf.gperf.m4 move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00
load-fragment.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
load-fragment.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
locale-setup.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
locale-setup.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
loopback-setup.c loopback: handle EPERM more gracefully 2012-04-13 18:52:53 +02:00
loopback-setup.h build-sys: move *-setup out of shared to avoid selinux being pulled in 2012-04-12 18:19:34 +02:00
machine-id-setup.c machine-id: fix spelling 2012-04-22 15:07:35 +02:00
machine-id-setup.h build-sys: move *-setup out of shared to avoid selinux being pulled in 2012-04-12 18:19:34 +02:00
main.c manager: drop MountAuto= and SwapAuto= options 2012-04-24 13:53:34 +02:00
Makefile build-sys: add stub makefiles to make emacs easier to use 2012-04-12 13:35:56 +02:00
manager.c core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
manager.h service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
mount-setup.c mount-setup: ignore common container bind mounts 2012-04-22 01:00:57 +02:00
mount-setup.h build-sys: move *-setup out of shared to avoid selinux being pulled in 2012-04-12 18:19:34 +02:00
mount.c service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
mount.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
namespace.c remove MS_* which can not be combined with current kernel code 2012-04-18 13:37:45 +02:00
namespace.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
org.freedesktop.systemd1.conf move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00
org.freedesktop.systemd1.policy.in.in move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00
org.freedesktop.systemd1.service move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00
path.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
path.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
securebits.h move libsystemd_core.la sources into core/ 2012-04-11 16:03:51 +02:00
selinux-setup.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
selinux-setup.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
service.c service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
service.h service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
shutdown.c shutdown: don't complain if we cannot lock memory, to make container shutdowns clean 2012-04-24 16:56:06 +02:00
snapshot.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
snapshot.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
socket.c service: introduce Type=idle and use it for gettys 2012-04-24 14:42:24 +02:00
socket.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
special.h remount: consolidate remount-api-vfs and remount-rootfs into one 2012-04-24 16:42:42 +02:00
swap.c remount: consolidate remount-api-vfs and remount-rootfs into one 2012-04-24 16:42:42 +02:00
swap.h manager: drop MountAuto= and SwapAuto= options 2012-04-24 13:53:34 +02:00
sysfs-show.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
system.conf manager: drop MountAuto= and SwapAuto= options 2012-04-24 13:53:34 +02:00
systemd.pc.in move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00
target.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
target.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
tcpwrap.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
tcpwrap.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
timer.c relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
timer.h relicense to LGPLv2.1 (with exceptions) 2012-04-12 00:24:39 +02:00
transaction.c core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
transaction.h transaction: add missing emacs and license headers 2012-04-22 15:22:27 +02:00
umount.c shutdown: move shutdown to core since it replaces PID 1 2012-04-12 14:18:36 +02:00
umount.h shutdown: move shutdown to core since it replaces PID 1 2012-04-12 14:18:36 +02:00
unit.c core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
unit.h core: add NOP jobs, job type collapsing 2012-04-25 18:38:27 +02:00
user.conf move more main systemd parts to core/ 2012-04-12 14:24:40 +02:00