bugfix: onion pending queue now works

and fixed recent memory leak


svn:r456
This commit is contained in:
Roger Dingledine 2003-09-14 08:17:14 +00:00
parent b63013e847
commit ebc23f690c
5 changed files with 16 additions and 10 deletions

View File

@ -383,7 +383,7 @@ int relay_check_recognized(circuit_t *circ, int cell_direction, char *stream, co
log_fn(LOG_DEBUG,"considered stream %d, not it.",*(int*)tmpconn->stream_id); log_fn(LOG_DEBUG,"considered stream %d, not it.",*(int*)tmpconn->stream_id);
} }
log_fn(LOG_DEBUG,"Didn't recognize. Giving up."); log_fn(LOG_DEBUG,"Didn't recognize on this iteration of decryption.");
return 0; return 0;
} }
@ -862,8 +862,8 @@ int circuit_finish_handshake(circuit_t *circ, char *reply) {
hop != circ->cpath && hop->state == CPATH_STATE_OPEN; hop != circ->cpath && hop->state == CPATH_STATE_OPEN;
hop=hop->next) ; hop=hop->next) ;
if(hop == circ->cpath) { /* got an extended when we're all done? */ if(hop == circ->cpath) { /* got an extended when we're all done? */
log_fn(LOG_INFO,"got extended when circ already built? Weird."); log_fn(LOG_INFO,"got extended when circ already built? Closing.");
return 0; return -1;
} }
} }
assert(hop->state == CPATH_STATE_AWAITING_KEYS); assert(hop->state == CPATH_STATE_AWAITING_KEYS);

View File

@ -349,6 +349,8 @@ static int connection_tls_finish_handshake(connection_t *conn) {
conn->pkey = pk; conn->pkey = pk;
conn->bandwidth = router->bandwidth; conn->bandwidth = router->bandwidth;
conn->addr = router->addr, conn->port = router->or_port; conn->addr = router->addr, conn->port = router->or_port;
if(conn->address)
free(conn->address);
conn->address = strdup(router->address); conn->address = strdup(router->address);
} }
} else { /* it's an OP */ } else { /* it's an OP */

View File

@ -102,13 +102,13 @@ int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int re
return 0; return 0;
} }
/* an incoming relay cell has arrived. return -1 if you want to tear down the
* circuit, else 0. */
int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn, int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection_t *conn,
int edge_type, crypt_path_t *layer_hint) { int edge_type, crypt_path_t *layer_hint) {
int relay_command; int relay_command;
static int num_seen=0; static int num_seen=0;
/* an incoming relay cell has arrived */
assert(cell && circ); assert(cell && circ);
relay_command = CELL_RELAY_COMMAND(*cell); relay_command = CELL_RELAY_COMMAND(*cell);
@ -148,7 +148,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) || if((edge_type == EDGE_AP && --layer_hint->deliver_window < 0) ||
(edge_type == EDGE_EXIT && --circ->deliver_window < 0)) { (edge_type == EDGE_EXIT && --circ->deliver_window < 0)) {
log_fn(LOG_DEBUG,"circ deliver_window below 0. Killing."); log_fn(LOG_DEBUG,"circ deliver_window below 0. Killing.");
return -1; /* XXX kill the whole circ? */ return -1;
} }
log_fn(LOG_DEBUG,"circ deliver_window now %d.", edge_type == EDGE_AP ? layer_hint->deliver_window : circ->deliver_window); log_fn(LOG_DEBUG,"circ deliver_window now %d.", edge_type == EDGE_AP ? layer_hint->deliver_window : circ->deliver_window);
@ -165,6 +165,7 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
return -1; /* somebody's breaking protocol. kill the whole circuit. */ return -1; /* somebody's breaking protocol. kill the whole circuit. */
} }
// printf("New text for buf (%d bytes): '%s'", cell->length - RELAY_HEADER_SIZE, cell->payload + RELAY_HEADER_SIZE);
if(connection_write_to_buf(cell->payload + RELAY_HEADER_SIZE, if(connection_write_to_buf(cell->payload + RELAY_HEADER_SIZE,
cell->length - RELAY_HEADER_SIZE, conn) < 0) { cell->length - RELAY_HEADER_SIZE, conn) < 0) {
conn->marked_for_close = 1; conn->marked_for_close = 1;

View File

@ -256,7 +256,7 @@ static void conn_read(int i) {
* discussion of POLLIN vs POLLHUP */ * discussion of POLLIN vs POLLHUP */
conn = connection_array[i]; conn = connection_array[i];
//log_fn(LOG_DEBUG,"socket %d has something to read.",conn->s); //log_fn(LOG_DEBUG,"socket %d wants to read.",conn->s);
if( if(
/* XXX does POLLHUP also mean it's definitely broken? */ /* XXX does POLLHUP also mean it's definitely broken? */
@ -300,7 +300,7 @@ static void check_conn_marked(int i) {
conn = connection_array[i]; conn = connection_array[i];
assert(conn); assert(conn);
if(conn->marked_for_close) { if(conn->marked_for_close) {
log(LOG_DEBUG,"check_conn_marked(): Cleaning up connection."); log_fn(LOG_DEBUG,"Cleaning up connection.");
if(conn->s >= 0) { /* might be an incomplete exit connection */ if(conn->s >= 0) { /* might be an incomplete exit connection */
/* FIXME there's got to be a better way to check for this -- and make other checks? */ /* FIXME there's got to be a better way to check for this -- and make other checks? */
connection_flush_buf(conn); /* flush it first */ connection_flush_buf(conn); /* flush it first */

View File

@ -59,6 +59,7 @@ int onion_pending_add(circuit_t *circ) {
} }
circuit_t *onion_next_task(void) { circuit_t *onion_next_task(void) {
circuit_t *circ;
if(!ol_list) if(!ol_list)
return NULL; /* no onions pending, we're done */ return NULL; /* no onions pending, we're done */
@ -71,7 +72,9 @@ circuit_t *onion_next_task(void) {
} }
assert(ol_length > 0); assert(ol_length > 0);
return ol_list->circ; circ = ol_list->circ;
onion_pending_remove(ol_list->circ);
return circ;
} }
/* go through ol_list, find the onion_queue_t element which points to /* go through ol_list, find the onion_queue_t element which points to
@ -95,7 +98,7 @@ void onion_pending_remove(circuit_t *circ) {
} else { /* we need to hunt through the rest of the list */ } else { /* we need to hunt through the rest of the list */
for( ;tmpo->next && tmpo->next->circ != circ; tmpo=tmpo->next) ; for( ;tmpo->next && tmpo->next->circ != circ; tmpo=tmpo->next) ;
if(!tmpo->next) { if(!tmpo->next) {
log(LOG_WARNING,"onion_pending_remove(): circ (p_aci %d), not in list!",circ->p_aci); log_fn(LOG_DEBUG,"circ (p_aci %d) not in list, probably at cpuworker.",circ->p_aci);
return; return;
} }
/* now we know tmpo->next->circ == circ */ /* now we know tmpo->next->circ == circ */