fix race between daemon-reload and other commands
authorDavid Tardon <dtardon@redhat.com>
Tue, 24 Apr 2018 13:19:38 +0000 (15:19 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 19 May 2018 09:37:00 +0000 (11:37 +0200)
commita7a7163df7fc8a9f794f6803b2f6c9c9b0745a1f
treece0eec239faa850f51854f73cafcf0aa3c47c7ca
parent90bc77af29abeb4be2de67939568da73fcec26e9
fix race between daemon-reload and other commands

When "systemctl daemon-reload" is run at the same time as "systemctl
start foo", the latter might hang. That's because commands like start
wait for JobRemoved signal to know when the job is finished. But if the
job is finished during reloading, the signal is never sent.

The hang can be easily reproduced by running

    # for ((N=1; N>0; N++)) ; do echo $N ; systemctl daemon-reload ; done
    # for ((N=1; N>0; N++)) ; do echo $N ; systemctl start systemd-coredump.socket ; done

in two different terminals. The start command will hang after 1-2
iterations.

This keeps track of jobs that were started before reload and finished
during it and sends JobRemoved after the reload has finished.
src/core/job.c
src/core/job.h
src/core/manager.c
src/core/manager.h