Implement proper event registration infrastucture for handling the
events coming in through the file descriptors. This makes it possible
to expand the polling code to arbitrary number of file descriptors.
All current users of the epoll have been converted to the new
infra. Some functions were moved higher in the file in order to make
it possible to reference them in the init_jobcontrol() function.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>