Refactor calculation of file descriptor ranges to close.
When the range of candidate file descriptors is very large, the code that
computes file descriptors to close when the daemon starts attempted to
allocate a large amount of memory and took a long time to compute.
Thanks to Alex Pyrgiotis for the timing test case.
This change avoids that resource-intensive computation, and significantly
improves the performance when importing the module and when starting the
daemon.
Thanks to Igor Kholopov for the implementation.