In-Flight Upgrade System, for integration.

The IFU system uses JSON to serialize and deserialize ircd state to disk,
re-execute itself (possibly with a newer binary) and pick up the fds which are
carried across the exec() call.

This allows the ircd to be upgraded without interrupting current connections.

Currently, listening fds are not preserved across exec(), which means that
users in the accept() queue and not yet accepted by the ircd might experience
some slight turbulence.

This patch must be used with current libmowgli-2, which has patches to make its
epoll/kqueue and DNS resolver socket fds close-on-exec. Failure to do so will
result in fd leakage of two descriptors per upgrade.

To initiate an upgrade, become an operator and run /UPGRADE.
The working directory from which the ircd was started must be writable.

The upgrade.json serialization file is currently not deleted after the upgrade
is completed to aid development. This should be changed at a later date to
enhance privacy.

RDNS queries should be reissued after an upgrade for clients which did not
complete the RDNS phase prior to the upgrade. This may result in some
duplicated queries issued to configured resolvers.

The restoration process now occurs after the configuration file is loaded.

The configuration file stored on disk MUST match that held in memory by the
current ircd before upgrading. This is not currently enforced or checked;
operator beware.

If an upgrade fails during the serialization phase, the ircd continues
operating. If an upgrade fails during the restoration phase (which is highly
unlikely), the ircd closes all fds and re-executes itself in normal mode. This
will disconnect all users but allow the ircd to continue with new connections.

This code has been tested with multiple servers. The sendq serialization system
has been load-tested with the /LIST output of a major network.

Signed-off-by: Hugo Landau <hlandau@devever.net>
Merge pull request #51 from hlandau/sam-upgrade-sq

In-Flight Upgrade System, for integration.