turn some knobs, add more debugging

svn:r1023
This commit is contained in:
Roger Dingledine
2004-01-30 19:31:39 +00:00
parent b42b16357f
commit afdaff63ef
3 changed files with 21 additions and 11 deletions
+17 -8
View File
@@ -250,10 +250,10 @@ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open) {
return NULL;
}
#define MIN_SECONDS_BEFORE_EXPIRING_CIRC 3
#define MIN_SECONDS_BEFORE_EXPIRING_CIRC 10
/* circuits that were born at the end of their second might be expired
* after 3.1 seconds; circuits born at the beginning might be expired
* after closer to 4 seconds.
* after 10.1 seconds; circuits born at the beginning might be expired
* after closer to 11 seconds.
*/
/* close all circuits that start at us, aren't open, and were born
@@ -275,6 +275,7 @@ void circuit_expire_building(void) {
else
log_fn(LOG_INFO,"Abandoning circ %d (state %d:%s)", victim->n_circ_id,
victim->state, circuit_state_to_string[victim->state]);
circuit_log_path(LOG_INFO,victim);
circuit_close(victim);
}
}
@@ -739,19 +740,26 @@ void circuit_about_to_close_connection(connection_t *conn) {
void circuit_log_path(int severity, circuit_t *circ) {
static char b[1024];
struct crypt_path_t *hop;
char *states[] = {"closed", "waiting for keys", "open"};
routerinfo_t *router;
assert(circ->cpath);
strcpy(b,"Stream is on circ: ");
for(hop=circ->cpath;hop->next != circ->cpath; hop=hop->next) {
sprintf(b,"circ (length %d, exit %s): ",
circ->build_state->desired_path_len, circ->build_state->chosen_exit);
hop=circ->cpath;
do {
router = router_get_by_addr_port(hop->addr,hop->port);
if(router) {
/* XXX strcat causes buffer overflow */
/* XXX strcat allows buffer overflow */
strcat(b,router->nickname);
strcat(b,",");
strcat(b,"(");
strcat(b,states[hop->state]);
strcat(b,"),");
} else {
strcat(b,"UNKNOWN,");
}
}
hop=hop->next;
} while(hop!=circ->cpath);
log_fn(severity,"%s",b);
}
@@ -1111,6 +1119,7 @@ int circuit_finish_handshake(circuit_t *circ, char *reply) {
hop->state = CPATH_STATE_OPEN;
log_fn(LOG_INFO,"finished");
circuit_log_path(LOG_WARN,circ);
return 0;
}
+2 -2
View File
@@ -341,9 +341,9 @@ static void run_scheduled_events(time_t now) {
}
time_to_new_circuit = now + options.NewCircuitPeriod;
}
#define CIRCUIT_MIN_BUILDING 2
#define CIRCUIT_MIN_BUILDING 3
if(!circ && circuit_count_building() < CIRCUIT_MIN_BUILDING) {
/* if there's no open circ, and less than 2 are on the way,
/* if there's no open circ, and less than 3 are on the way,
* go ahead and try another.
*/
circuit_launch_new();
+2 -1
View File
@@ -475,7 +475,8 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
add_nickname_list_to_smartlist(excludednodes,options.ExcludedNodes);
if(cur_len == state->desired_path_len - 1) { /* Picking last node */
log_fn(LOG_DEBUG, "Contemplating last hop: choice already made.");
log_fn(LOG_DEBUG, "Contemplating last hop: choice already made: %s",
state->chosen_exit);
choice = router_get_by_nickname(state->chosen_exit);
if(!choice) {
log_fn(LOG_WARN,"Our chosen exit %s is no longer in the directory? Failing.",