Loading changes/ticket15176 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code simplification and refactoring: - Refactor main loop to extract the 'loop' part. This makes it easier to run Tor under Shadow. Closes ticket 15176. src/or/main.c +66 −39 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ static void second_elapsed_callback(periodic_timer_t *timer, void *args); static int conn_close_if_marked(int i); static void connection_start_reading_from_linked_conn(connection_t *conn); static int connection_should_read_from_linked_conn(connection_t *conn); static int run_main_loop_until_done(void); /********* START VARIABLES **********/ Loading Loading @@ -1955,7 +1956,6 @@ do_hup(void) int do_main_loop(void) { int loop_result; time_t now; /* initialize dns resolve map, spawn workers if needed */ Loading Loading @@ -2084,7 +2084,18 @@ do_main_loop(void) } #endif for (;;) { return run_main_loop_until_done(); } /** * Run the main loop a single time. Return 0 for "exit"; -1 for "exit with * error", and 1 for "run this again." */ static int run_main_loop_once(void) { int loop_result; if (nt_service_is_stopping()) return 0; Loading Loading @@ -2125,10 +2136,26 @@ do_main_loop(void) log_debug(LD_NET,"libevent call interrupted."); /* You can't trust the results of this poll(). Go back to the * top of the big for loop. */ continue; return 1; } } return 1; } /** Run the run_main_loop_once() function until it declares itself done, * and return its final return value. * * Shadow won't invoke this function, so don't fill it up with things. */ static int run_main_loop_until_done(void) { int loop_result = 1; do { loop_result = run_main_loop_once(); } while (loop_result == 1); return loop_result; } #ifndef _WIN32 /* Only called when we're willing to use signals */ Loading Loading
changes/ticket15176 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code simplification and refactoring: - Refactor main loop to extract the 'loop' part. This makes it easier to run Tor under Shadow. Closes ticket 15176.
src/or/main.c +66 −39 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ static void second_elapsed_callback(periodic_timer_t *timer, void *args); static int conn_close_if_marked(int i); static void connection_start_reading_from_linked_conn(connection_t *conn); static int connection_should_read_from_linked_conn(connection_t *conn); static int run_main_loop_until_done(void); /********* START VARIABLES **********/ Loading Loading @@ -1955,7 +1956,6 @@ do_hup(void) int do_main_loop(void) { int loop_result; time_t now; /* initialize dns resolve map, spawn workers if needed */ Loading Loading @@ -2084,7 +2084,18 @@ do_main_loop(void) } #endif for (;;) { return run_main_loop_until_done(); } /** * Run the main loop a single time. Return 0 for "exit"; -1 for "exit with * error", and 1 for "run this again." */ static int run_main_loop_once(void) { int loop_result; if (nt_service_is_stopping()) return 0; Loading Loading @@ -2125,10 +2136,26 @@ do_main_loop(void) log_debug(LD_NET,"libevent call interrupted."); /* You can't trust the results of this poll(). Go back to the * top of the big for loop. */ continue; return 1; } } return 1; } /** Run the run_main_loop_once() function until it declares itself done, * and return its final return value. * * Shadow won't invoke this function, so don't fill it up with things. */ static int run_main_loop_until_done(void) { int loop_result = 1; do { loop_result = run_main_loop_once(); } while (loop_result == 1); return loop_result; } #ifndef _WIN32 /* Only called when we're willing to use signals */ Loading