]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
bugfix: onion pending queue now works
authorRoger Dingledine <arma@torproject.org>
Sun, 14 Sep 2003 08:17:14 +0000 (08:17 +0000)
committerRoger Dingledine <arma@torproject.org>
Sun, 14 Sep 2003 08:17:14 +0000 (08:17 +0000)
and fixed recent memory leak

svn:r456

src/or/circuit.c
src/or/connection.c
src/or/connection_edge.c
src/or/main.c
src/or/onion.c

index 9eb9cc10a82a60f8b8d7b5f9a34f111ac8d41c3b..65a1f4e0da9630a392fd7daf88c85365867af335 100644 (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,"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);
index 1cf6f619a19fbedec21076287ff0a8c6f4acf571..73cefee98bedfb27fe00ed44ee793c0450f7278a 100644 (file)
@@ -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 */
index 7560a61a709a5af65151a9854e248c6d90619ce5..7a461a697b459512978ed5e596f6072edd3cb8a1 100644 (file)
@@ -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;
index 3fe57fcdb5ccfd275a5f9325eec1d3155017f647..310ca3df6976b535e2672f33bed46339ac532a52 100644 (file)
@@ -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 */
index 7104de109994b8e0acd444c267a84f9d7e1edf02..1ba4c1789ac146ebdbe021288f3b140ecd5e68ce 100644 (file)
@@ -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 */