mainloop: factor out main thread calling functions to separate module

All of the main_loop_call() function and its related implementation
code is extracted to a separate module for mainloop.c to make mainloop.c
smaller and to make internal layering more visible.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop: refactor signals to use a small helper function

That makes the signal setup code easier to read.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop: refactor event registration to use a small helper function

This patch makes mainloop_init_events() to be easier to read.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop: move res_init() to app_post_config_loaded()

Instead of pulling in more dependencies to mainloop, use apphook to
reinitialize the system resolver at every SIGHUP.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop: remove unneeded headers

With the latest mainloop refactor a great number of header inclusions
could be removed. This patch does exactly that.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
mainloop-worker: remove worker thread signal setup

We used to require SIG_BLOCKing a number of signals in worker threads as
we pretty much relied on SIGHUP/SIGTERM/SIGCHLD/SIGINT to arrive to the
main thread. This is not guaranteed by POSIX however.

In POSIX signals are delivered to a process, and the OS is free to choose
a random thread to deliver that signal to, assuming the signal is not
blocked there.

That was the reason we blocked these signals everywhere except the
main thread.

Stuff however changed when we switched to a multithreaded architecture and
started using libivykis. ivykis pretty much handles this just fine by
rerouting signals to callbacks in the thread that registered the interest.

That way, it doesn't really matter which thread the signal is delivered
to it is taken care of.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>