[tor-commits] [tor/master] Extract main part of main loop into a separate function