mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
general cleanups
svn:r889
This commit is contained in:
parent
6a968495b1
commit
8bd7c94bf6
@ -665,6 +665,10 @@ int connection_process_inbuf(connection_t *conn) {
|
|||||||
return connection_or_process_inbuf(conn);
|
return connection_or_process_inbuf(conn);
|
||||||
case CONN_TYPE_EXIT:
|
case CONN_TYPE_EXIT:
|
||||||
case CONN_TYPE_AP:
|
case CONN_TYPE_AP:
|
||||||
|
if(conn->package_window <= 0) {
|
||||||
|
log_fn(LOG_WARN,"called with package_window %d. Tell Roger.", conn->package_window);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return connection_edge_process_inbuf(conn);
|
return connection_edge_process_inbuf(conn);
|
||||||
case CONN_TYPE_DIR:
|
case CONN_TYPE_DIR:
|
||||||
return connection_dir_process_inbuf(conn);
|
return connection_dir_process_inbuf(conn);
|
||||||
|
@ -408,7 +408,8 @@ int connection_edge_finished_flushing(connection_t *conn) {
|
|||||||
if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
|
if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
|
||||||
RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
|
RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
|
||||||
return 0; /* circuit is closed, don't continue */
|
return 0; /* circuit is closed, don't continue */
|
||||||
return connection_process_inbuf(conn); /* in case the server has written anything */
|
assert(conn->package_window > 0);
|
||||||
|
return connection_edge_process_inbuf(conn); /* in case the server has written anything */
|
||||||
case AP_CONN_STATE_OPEN:
|
case AP_CONN_STATE_OPEN:
|
||||||
case EXIT_CONN_STATE_OPEN:
|
case EXIT_CONN_STATE_OPEN:
|
||||||
connection_stop_writing(conn);
|
connection_stop_writing(conn);
|
||||||
|
@ -34,8 +34,9 @@ static int ol_length=0;
|
|||||||
int onion_pending_add(circuit_t *circ) {
|
int onion_pending_add(circuit_t *circ) {
|
||||||
struct onion_queue_t *tmp;
|
struct onion_queue_t *tmp;
|
||||||
|
|
||||||
tmp = tor_malloc_zero(sizeof(struct onion_queue_t));
|
tmp = tor_malloc(sizeof(struct onion_queue_t));
|
||||||
tmp->circ = circ;
|
tmp->circ = circ;
|
||||||
|
tmp->next = NULL;
|
||||||
|
|
||||||
if(!ol_tail) {
|
if(!ol_tail) {
|
||||||
assert(!ol_list);
|
assert(!ol_list);
|
||||||
@ -70,14 +71,6 @@ circuit_t *onion_next_task(void) {
|
|||||||
|
|
||||||
assert(ol_list->circ);
|
assert(ol_list->circ);
|
||||||
assert(ol_list->circ->p_conn); /* make sure it's still valid */
|
assert(ol_list->circ->p_conn); /* make sure it's still valid */
|
||||||
#if 0
|
|
||||||
if(!ol_list->circ->p_conn) {
|
|
||||||
log_fn(LOG_INFO,"ol_list->circ->p_conn null, must have died?");
|
|
||||||
onion_pending_remove(ol_list->circ);
|
|
||||||
return onion_next_task(); /* recurse: how about the next one? */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(ol_length > 0);
|
assert(ol_length > 0);
|
||||||
circ = ol_list->circ;
|
circ = ol_list->circ;
|
||||||
onion_pending_remove(ol_list->circ);
|
onion_pending_remove(ol_list->circ);
|
||||||
@ -182,7 +175,7 @@ char **parse_nickname_list(char *list, int *num) {
|
|||||||
strncpy(out[i],start,end-start);
|
strncpy(out[i],start,end-start);
|
||||||
out[i][end-start] = 0; /* null terminate it */
|
out[i][end-start] = 0; /* null terminate it */
|
||||||
i++;
|
i++;
|
||||||
while(isspace(*end)) end++;
|
while(*end && isspace(*end)) end++;
|
||||||
start = end;
|
start = end;
|
||||||
}
|
}
|
||||||
*num = i;
|
*num = i;
|
||||||
@ -209,15 +202,11 @@ static int new_route_len(double cw, routerinfo_t **rarray, int rarray_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(num_acceptable_routers < routelen) {
|
if(num_acceptable_routers < routelen) {
|
||||||
log_fn(LOG_INFO,"Not enough routers: cutting routelen from %d to %d.",routelen, num_acceptable_routers);
|
log_fn(LOG_INFO,"Not enough routers: cutting routelen from %d to %d.",
|
||||||
|
routelen, num_acceptable_routers);
|
||||||
routelen = num_acceptable_routers;
|
routelen = num_acceptable_routers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (routelen < 1) {
|
|
||||||
log_fn(LOG_WARN,"Didn't find any acceptable routers. Failing.");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return routelen;
|
return routelen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,7 +305,8 @@ static routerinfo_t *choose_good_exit_server(routerlist_t *dir)
|
|||||||
++n_best_maybe_support;
|
++n_best_maybe_support;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log_fn(LOG_INFO, "Found %d servers that will definitely support %d/%d pending connections, and %d that might support %d/%d.",
|
log_fn(LOG_INFO, "Found %d servers that will definitely support %d/%d "
|
||||||
|
"pending connections, and %d that might support %d/%d.",
|
||||||
n_best_support, best_support, n_pending_connections,
|
n_best_support, best_support, n_pending_connections,
|
||||||
n_best_maybe_support, best_maybe_support, n_pending_connections);
|
n_best_maybe_support, best_maybe_support, n_pending_connections);
|
||||||
/* If any routers definitely support any pending connections, choose one
|
/* If any routers definitely support any pending connections, choose one
|
||||||
@ -469,10 +459,9 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
|
|||||||
log_fn(LOG_DEBUG, "Picked an already-selected router for hop %d; retrying.",
|
log_fn(LOG_DEBUG, "Picked an already-selected router for hop %d; retrying.",
|
||||||
cur_len);
|
cur_len);
|
||||||
++n_failures;
|
++n_failures;
|
||||||
if (n_failures == 25) {
|
if (n_failures == 50) {
|
||||||
/* This actually happens with P=1/30,000,000 when we _could_ build a
|
/* XXX hack to prevent infinite loop. Ideally we should build a list
|
||||||
* circuit. For now, let's leave it in.
|
* of acceptable choices and then choose from it. */
|
||||||
*/
|
|
||||||
log_fn(LOG_INFO, "Unable to continue generating circuit path");
|
log_fn(LOG_INFO, "Unable to continue generating circuit path");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -505,21 +494,19 @@ int onion_extend_cpath(crypt_path_t **head_ptr, cpath_build_state_t *state, rout
|
|||||||
choice->nickname, cur_len, state->chosen_exit);
|
choice->nickname, cur_len, state->chosen_exit);
|
||||||
if (cur_len != state->desired_path_len-1 &&
|
if (cur_len != state->desired_path_len-1 &&
|
||||||
!strcasecmp(choice->nickname, state->chosen_exit)) {
|
!strcasecmp(choice->nickname, state->chosen_exit)) {
|
||||||
|
/* make sure we don't pick the exit for another node in the path */
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, cpath = *head_ptr; i < cur_len; ++i, cpath=cpath->next) {
|
for (i = 0, cpath = *head_ptr; i < cur_len; ++i, cpath=cpath->next) {
|
||||||
r = router_get_by_addr_port(cpath->addr, cpath->port);
|
r = router_get_by_addr_port(cpath->addr, cpath->port);
|
||||||
if ((r && !crypto_pk_cmp_keys(r->onion_pkey, choice->onion_pkey))
|
assert(r);
|
||||||
|| (cur_len != state->desired_path_len-1 &&
|
if (!crypto_pk_cmp_keys(r->onion_pkey, choice->onion_pkey))
|
||||||
!strcasecmp(choice->nickname, state->chosen_exit))
|
goto again; /* same key -- it or a twin is already chosen */
|
||||||
|| (cpath->addr == choice->addr &&
|
if (options.ORPort &&
|
||||||
cpath->port == choice->or_port)
|
!(connection_twin_get_by_addr_port(choice->addr, choice->or_port)))
|
||||||
|| (options.ORPort &&
|
goto again; /* this node is not connected to us. */
|
||||||
!(connection_twin_get_by_addr_port(choice->addr,
|
|
||||||
choice->or_port)))) {
|
|
||||||
goto again;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Okay, so we haven't used 'choice' before. */
|
/* Okay, so we haven't used 'choice' before. */
|
||||||
|
Loading…
Reference in New Issue
Block a user