Refactor main loop for Shadow
Let's make it easier to run Shadow. Shadow has its own main loop. When calling into Tor, Tor should not loop infinitely, else Shadow will 'freeze' in Tor's loop and not work properly. Separating the main loop into the main parts, and the then each iteration of the loop into a separate function will make this easier.
Patch attached, created from Tor master.