Loading changes/no_global_ccc 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code Simplification and Refactoring: - Stop using can_complete_circuits as a global variable; access it with a function instead. src/or/circuitbuild.c +4 −3 Original line number Diff line number Diff line Loading @@ -943,9 +943,9 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) circuit_rep_hist_note_result(circ); circuit_has_opened(circ); /* do other actions as necessary */ if (!can_complete_circuit && !circ->build_state->onehop_tunnel) { if (!have_completed_a_circuit() && !circ->build_state->onehop_tunnel) { const or_options_t *options = get_options(); can_complete_circuit=1; note_that_we_completed_a_circuit(); /* FFFF Log a count of known routers here */ log_notice(LD_GENERAL, "Tor has successfully opened a circuit. " Loading Loading @@ -1033,7 +1033,8 @@ circuit_note_clock_jumped(int seconds_elapsed) seconds_elapsed >=0 ? "forward" : "backward"); control_event_general_status(LOG_WARN, "CLOCK_JUMPED TIME=%d", seconds_elapsed); can_complete_circuit=0; /* so it'll log when it works again */ /* so we log when it works again */ note_that_we_maybe_cant_complete_circuits(); control_event_client_status(severity, "CIRCUIT_NOT_ESTABLISHED REASON=%s", "CLOCK_JUMPED"); circuit_mark_all_unused_circs(); Loading src/or/config.c +2 −2 Original line number Diff line number Diff line Loading @@ -1072,7 +1072,7 @@ options_act_reversible(const or_options_t *old_options, char **msg) "connections."); connection_mark_all_noncontrol_connections(); /* We can't complete circuits until the network is re-enabled. */ can_complete_circuit = 0; note_that_we_maybe_cant_complete_circuits(); } } Loading Loading @@ -1670,7 +1670,7 @@ options_act(const or_options_t *old_options) if (server_mode(options) && !server_mode(old_options)) { ip_address_changed(0); if (can_complete_circuit || !any_predicted_circuits(time(NULL))) if (have_completed_a_circuit() || !any_predicted_circuits(time(NULL))) inform_testing_reachability(); } cpuworkers_rotate(); Loading src/or/control.c +1 −1 Original line number Diff line number Diff line Loading @@ -2015,7 +2015,7 @@ getinfo_helper_events(control_connection_t *control_conn, /* Note that status/ is not a catch-all for events; there's only supposed * to be a status GETINFO if there's a corresponding STATUS event. */ if (!strcmp(question, "status/circuit-established")) { *answer = tor_strdup(can_complete_circuit ? "1" : "0"); *answer = tor_strdup(have_completed_a_circuit() ? "1" : "0"); } else if (!strcmp(question, "status/enough-dir-info")) { *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0"); } else if (!strcmp(question, "status/good-server-descriptor") || Loading src/or/main.c +36 −10 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ static int called_loop_once = 0; * any longer (a big time jump happened, when we notice our directory is * heinously out-of-date, etc. */ int can_complete_circuit=0; static int can_complete_circuits = 0; /** How often do we check for router descriptors that we should download * when we have too little directory info? */ Loading Loading @@ -223,6 +223,32 @@ set_buffer_lengths_to_zero(tor_socket_t s) } #endif /** Return 1 if we have successfully built a circuit, and nothing has changed * to make us think that maybe we can't. */ int have_completed_a_circuit(void) { return can_complete_circuits; } /** Note that we have successfully built a circuit, so that reachability * testing and introduction points and so on may be attempted. */ void note_that_we_completed_a_circuit(void) { can_complete_circuits = 1; } /** Note that something has happened (like a clock jump, or DisableNetwork) to * make us think that maybe we can't complete circuits. */ void note_that_we_maybe_cant_complete_circuits(void) { can_complete_circuits = 0; } /** Add <b>conn</b> to the array of connections that we can poll on. The * connection's socket must be set; the connection starts out * non-reading and non-writing. Loading Loading @@ -999,7 +1025,7 @@ directory_info_has_arrived(time_t now, int from_cache) } if (server_mode(options) && !net_is_disabled() && !from_cache && (can_complete_circuit || !any_predicted_circuits(now))) (have_completed_a_circuit() || !any_predicted_circuits(now))) consider_testing_reachability(1, 1); } Loading Loading @@ -1436,7 +1462,7 @@ run_scheduled_events(time_t now) /* also, check religiously for reachability, if it's within the first * 20 minutes of our uptime. */ if (is_server && (can_complete_circuit || !any_predicted_circuits(now)) && (have_completed_a_circuit() || !any_predicted_circuits(now)) && !we_are_hibernating()) { if (stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { consider_testing_reachability(1, dirport_reachability_count==0); Loading Loading @@ -1549,7 +1575,7 @@ run_scheduled_events(time_t now) circuit_close_all_marked(); /* 7. And upload service descriptors if necessary. */ if (can_complete_circuit && !net_is_disabled()) { if (have_completed_a_circuit() && !net_is_disabled()) { rend_consider_services_upload(now); rend_consider_descriptor_republication(); } Loading Loading @@ -1680,7 +1706,7 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg) if (server_mode(options) && !net_is_disabled() && seconds_elapsed > 0 && can_complete_circuit && have_completed_a_circuit() && stats_n_seconds_working / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT != (stats_n_seconds_working+seconds_elapsed) / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { Loading Loading
changes/no_global_ccc 0 → 100644 +3 −0 Original line number Diff line number Diff line o Code Simplification and Refactoring: - Stop using can_complete_circuits as a global variable; access it with a function instead.
src/or/circuitbuild.c +4 −3 Original line number Diff line number Diff line Loading @@ -943,9 +943,9 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) circuit_rep_hist_note_result(circ); circuit_has_opened(circ); /* do other actions as necessary */ if (!can_complete_circuit && !circ->build_state->onehop_tunnel) { if (!have_completed_a_circuit() && !circ->build_state->onehop_tunnel) { const or_options_t *options = get_options(); can_complete_circuit=1; note_that_we_completed_a_circuit(); /* FFFF Log a count of known routers here */ log_notice(LD_GENERAL, "Tor has successfully opened a circuit. " Loading Loading @@ -1033,7 +1033,8 @@ circuit_note_clock_jumped(int seconds_elapsed) seconds_elapsed >=0 ? "forward" : "backward"); control_event_general_status(LOG_WARN, "CLOCK_JUMPED TIME=%d", seconds_elapsed); can_complete_circuit=0; /* so it'll log when it works again */ /* so we log when it works again */ note_that_we_maybe_cant_complete_circuits(); control_event_client_status(severity, "CIRCUIT_NOT_ESTABLISHED REASON=%s", "CLOCK_JUMPED"); circuit_mark_all_unused_circs(); Loading
src/or/config.c +2 −2 Original line number Diff line number Diff line Loading @@ -1072,7 +1072,7 @@ options_act_reversible(const or_options_t *old_options, char **msg) "connections."); connection_mark_all_noncontrol_connections(); /* We can't complete circuits until the network is re-enabled. */ can_complete_circuit = 0; note_that_we_maybe_cant_complete_circuits(); } } Loading Loading @@ -1670,7 +1670,7 @@ options_act(const or_options_t *old_options) if (server_mode(options) && !server_mode(old_options)) { ip_address_changed(0); if (can_complete_circuit || !any_predicted_circuits(time(NULL))) if (have_completed_a_circuit() || !any_predicted_circuits(time(NULL))) inform_testing_reachability(); } cpuworkers_rotate(); Loading
src/or/control.c +1 −1 Original line number Diff line number Diff line Loading @@ -2015,7 +2015,7 @@ getinfo_helper_events(control_connection_t *control_conn, /* Note that status/ is not a catch-all for events; there's only supposed * to be a status GETINFO if there's a corresponding STATUS event. */ if (!strcmp(question, "status/circuit-established")) { *answer = tor_strdup(can_complete_circuit ? "1" : "0"); *answer = tor_strdup(have_completed_a_circuit() ? "1" : "0"); } else if (!strcmp(question, "status/enough-dir-info")) { *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0"); } else if (!strcmp(question, "status/good-server-descriptor") || Loading
src/or/main.c +36 −10 Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ static int called_loop_once = 0; * any longer (a big time jump happened, when we notice our directory is * heinously out-of-date, etc. */ int can_complete_circuit=0; static int can_complete_circuits = 0; /** How often do we check for router descriptors that we should download * when we have too little directory info? */ Loading Loading @@ -223,6 +223,32 @@ set_buffer_lengths_to_zero(tor_socket_t s) } #endif /** Return 1 if we have successfully built a circuit, and nothing has changed * to make us think that maybe we can't. */ int have_completed_a_circuit(void) { return can_complete_circuits; } /** Note that we have successfully built a circuit, so that reachability * testing and introduction points and so on may be attempted. */ void note_that_we_completed_a_circuit(void) { can_complete_circuits = 1; } /** Note that something has happened (like a clock jump, or DisableNetwork) to * make us think that maybe we can't complete circuits. */ void note_that_we_maybe_cant_complete_circuits(void) { can_complete_circuits = 0; } /** Add <b>conn</b> to the array of connections that we can poll on. The * connection's socket must be set; the connection starts out * non-reading and non-writing. Loading Loading @@ -999,7 +1025,7 @@ directory_info_has_arrived(time_t now, int from_cache) } if (server_mode(options) && !net_is_disabled() && !from_cache && (can_complete_circuit || !any_predicted_circuits(now))) (have_completed_a_circuit() || !any_predicted_circuits(now))) consider_testing_reachability(1, 1); } Loading Loading @@ -1436,7 +1462,7 @@ run_scheduled_events(time_t now) /* also, check religiously for reachability, if it's within the first * 20 minutes of our uptime. */ if (is_server && (can_complete_circuit || !any_predicted_circuits(now)) && (have_completed_a_circuit() || !any_predicted_circuits(now)) && !we_are_hibernating()) { if (stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { consider_testing_reachability(1, dirport_reachability_count==0); Loading Loading @@ -1549,7 +1575,7 @@ run_scheduled_events(time_t now) circuit_close_all_marked(); /* 7. And upload service descriptors if necessary. */ if (can_complete_circuit && !net_is_disabled()) { if (have_completed_a_circuit() && !net_is_disabled()) { rend_consider_services_upload(now); rend_consider_descriptor_republication(); } Loading Loading @@ -1680,7 +1706,7 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg) if (server_mode(options) && !net_is_disabled() && seconds_elapsed > 0 && can_complete_circuit && have_completed_a_circuit() && stats_n_seconds_working / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT != (stats_n_seconds_working+seconds_elapsed) / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) { Loading