summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-09-14 08:17:14 +0000
committerRoger Dingledine <arma@torproject.org>2003-09-14 08:17:14 +0000
commitebc23f690c38e70bfe1eb6aaa56a5c4eb9e35be4 (patch)
treeeb5b8c810fdabfbcb1be4d0576bbe31484e63b79
parentb63013e8470a2d44036d8157344484c2f4d8c6cd (diff)
downloadtor-ebc23f690c38e70bfe1eb6aaa56a5c4eb9e35be4.tar.gz
tor-ebc23f690c38e70bfe1eb6aaa56a5c4eb9e35be4.zip
bugfix: onion pending queue now works
and fixed recent memory leak svn:r456
-rw-r--r--src/or/circuit.c6
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/connection_edge.c7
-rw-r--r--src/or/main.c4
-rw-r--r--src/or/onion.c7
5 files changed, 16 insertions, 10 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 9eb9cc10a8..65a1f4e0da 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -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,"Didn't recognize. Giving up.");
+ log_fn(LOG_DEBUG,"Didn't recognize on this iteration of decryption.");
return 0;
}
@@ -862,8 +862,8 @@ int circuit_finish_handshake(circuit_t *circ, char *reply) {
hop != circ->cpath && hop->state == CPATH_STATE_OPEN;
hop=hop->next) ;
if(hop == circ->cpath) { /* got an extended when we're all done? */
- log_fn(LOG_INFO,"got extended when circ already built? Weird.");
- return 0;
+ log_fn(LOG_INFO,"got extended when circ already built? Closing.");
+ return -1;
}
}
assert(hop->state == CPATH_STATE_AWAITING_KEYS);
diff --git a/src/or/connection.c b/src/or/connection.c
index 1cf6f619a1..73cefee98b 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -349,6 +349,8 @@ static int connection_tls_finish_handshake(connection_t *conn) {
conn->pkey = pk;
conn->bandwidth = router->bandwidth;
conn->addr = router->addr, conn->port = router->or_port;
+ if(conn->address)
+ free(conn->address);
conn->address = strdup(router->address);
}
} else { /* it's an OP */
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 7560a61a70..7a461a697b 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -102,13 +102,13 @@ int connection_edge_send_command(connection_t *fromconn, circuit_t *circ, int re
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 edge_type, crypt_path_t *layer_hint) {
int relay_command;
static int num_seen=0;
- /* an incoming relay cell has arrived */
-
assert(cell && circ);
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) ||
(edge_type == EDGE_EXIT && --circ->deliver_window < 0)) {
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);
@@ -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. */
}
+// 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,
cell->length - RELAY_HEADER_SIZE, conn) < 0) {
conn->marked_for_close = 1;
diff --git a/src/or/main.c b/src/or/main.c
index 3fe57fcdb5..310ca3df69 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -256,7 +256,7 @@ static void conn_read(int i) {
* discussion of POLLIN vs POLLHUP */
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(
/* XXX does POLLHUP also mean it's definitely broken? */
@@ -300,7 +300,7 @@ static void check_conn_marked(int i) {
conn = connection_array[i];
assert(conn);
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 */
/* FIXME there's got to be a better way to check for this -- and make other checks? */
connection_flush_buf(conn); /* flush it first */
diff --git a/src/or/onion.c b/src/or/onion.c
index 7104de1099..1ba4c1789a 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -59,6 +59,7 @@ int onion_pending_add(circuit_t *circ) {
}
circuit_t *onion_next_task(void) {
+ circuit_t *circ;
if(!ol_list)
return NULL; /* no onions pending, we're done */
@@ -71,7 +72,9 @@ circuit_t *onion_next_task(void) {
}
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
@@ -95,7 +98,7 @@ void onion_pending_remove(circuit_t *circ) {
} else { /* we need to hunt through the rest of the list */
for( ;tmpo->next && tmpo->next->circ != circ; tmpo=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;
}
/* now we know tmpo->next->circ == circ */