puppetlabs/puppet — pull request #1627 by zaphod42 (2013-05-01 20:14:59+00:00)
Title: (#20447) Wait for server to shutdown before exiting daemon

Previously, if the filetimeout was set to 0 and the puppet master was run,
the master would exit immediately. This was caused by the scheduler having
nothing to do and the new logic for it causes it to stop running at that
point (because once there is nothing to do, there is also no chance that
something will cause it to having something to do). There was a slightly
wrong assumption that was being made for that logic: the scheduler is in
control of all activity in the daemonized process. This is not the case.

The daemon has 3 parts to it:
* configuration reparse
* agent runs
* server control

The server does not take part in the scheduler inside the daemon. It is
assumed to be a separate thread/process, which the daemon will kick off when
it starts, and stop when the daemon is told to stop. When the
"start" method of the daemon exits, the daemon itself exits and the server
will be required to shut down.

There are 2 ways that could be used to solve this problem: have the scheduler
sit in a busy loop (or sleep forever) when it has nothing to do, or wait for
the server to finish before the daemon considers itself done. This commit
uses the latter option.

The new code will wait for the server to finish before the Daemon#start
method returns. This makes the dependency explicit rather than hidden in an
infinite loop in the scheduler.