]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
fix many bugs in package_window handling
authorRoger Dingledine <arma@torproject.org>
Thu, 3 Jul 2003 03:40:47 +0000 (03:40 +0000)
committerRoger Dingledine <arma@torproject.org>
Thu, 3 Jul 2003 03:40:47 +0000 (03:40 +0000)
svn:r363

src/or/circuit.c
src/or/connection.c
src/or/connection_edge.c
src/or/connection_or.c

index eab3d78904a8133668e2f6cd31ab3a7522dd01c6..98f0b1443023a1ef04ce4635f421b2e4f57a2e9c 100644 (file)
@@ -405,9 +405,10 @@ void circuit_resume_edge_reading(circuit_t *circ, int edge_type, crypt_path_t *l
        (edge_type == EDGE_AP   && conn->package_window > 0 && conn->cpath_layer == layer_hint)) {
       connection_start_reading(conn);
       connection_package_raw_inbuf(conn); /* handle whatever might still be on the inbuf */
+      if(circuit_consider_stop_edge_reading(circ, edge_type, layer_hint))
+        return;
     }
   }
-  circuit_consider_stop_edge_reading(circ, edge_type, layer_hint);
 }
 
 /* returns 1 if the window is empty, else 0. If it's empty, tell edge conns to stop reading. */
index 2d3a9cc43442ef096c66aaf78962b43239ef4de8..ce56c2f05d3a34d715c5e95e5a2ae076fa8b27dc 100644 (file)
@@ -550,12 +550,20 @@ int connection_package_raw_inbuf(connection_t *conn) {
 
   assert(conn);
   assert(!connection_speaks_cells(conn));
-  /* this function should never get called if either package_window is 0 */
+
 repeat_connection_package_raw_inbuf:
 
+  circ = circuit_get_by_conn(conn);
+  if(!circ) {
+    log_fn(LOG_DEBUG,"conn has no circuits!");
+    return -1;
+  }
+
+  if(circuit_consider_stop_edge_reading(circ, conn->type, conn->cpath_layer))
+    return 0;
+
   amount_to_process = conn->inbuf_datalen;
-  
+
   if(!amount_to_process)
     return 0;
 
@@ -570,12 +578,6 @@ repeat_connection_package_raw_inbuf:
 
   connection_fetch_from_buf(cell.payload+RELAY_HEADER_SIZE, cell.length, conn);
 
-  circ = circuit_get_by_conn(conn);
-  if(!circ) {
-    log_fn(LOG_DEBUG,"conn has no circuits!");
-    return -1;
-  }
-
   log_fn(LOG_DEBUG,"(%d) Packaging %d bytes (%d waiting).",conn->s,cell.length, conn->inbuf_datalen);
 
 
@@ -605,14 +607,11 @@ repeat_connection_package_raw_inbuf:
     conn->cpath_layer->package_window--;
   }
 
-  if(circuit_consider_stop_edge_reading(circ,
-     conn->type == CONN_TYPE_EXIT ? EDGE_EXIT : EDGE_AP, conn->cpath_layer))
-    return 0;
-
   assert(conn->package_window > 0);
   if(--conn->package_window <= 0) { /* is it 0 after decrement? */
     connection_stop_reading(conn);
     log_fn(LOG_DEBUG,"conn->package_window reached 0.");
+    circuit_consider_stop_edge_reading(circ, conn->type, conn->cpath_layer);
     return 0; /* don't process the inbuf any more */
   }
   log_fn(LOG_DEBUG,"conn->package_window is %d",conn->package_window);
index 5ae9a85a43a2cbbcecdbeb920e7497a760599cfd..165db46e6d36cf1d7ddabe67bc5cf167ab2e8753 100644 (file)
@@ -50,7 +50,6 @@ int connection_edge_process_inbuf(connection_t *conn) {
     case EXIT_CONN_STATE_OPEN:
       if(connection_package_raw_inbuf(conn) < 0)
         return -1;
-      circuit_consider_stop_edge_reading(circuit_get_by_conn(conn), conn->type == CONN_TYPE_AP ? EDGE_AP : EDGE_EXIT, conn->cpath_layer);
       return 0;
     case EXIT_CONN_STATE_CONNECTING:
       log_fn(LOG_DEBUG,"text from server while in 'connecting' state at exit. Leaving it on buffer.");
@@ -247,9 +246,9 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, connection
         return 0;
       }
       conn->package_window += STREAMWINDOW_INCREMENT;
+      log_fn(LOG_DEBUG,"stream-level sendme, packagewindow now %d.", conn->package_window);
       connection_start_reading(conn);
-      if(!circuit_consider_stop_edge_reading(circ, edge_type, layer_hint))
-        connection_package_raw_inbuf(conn); /* handle whatever might still be on the inbuf */
+      connection_package_raw_inbuf(conn); /* handle whatever might still be on the inbuf */
       break;
     default:
       log_fn(LOG_DEBUG,"unknown relay command %d.",relay_command);
index b5f63d48b91624a653efb6252ceaad409f770226..683c966554ec9eae769df6329da794205cb3aa1f 100644 (file)
@@ -205,7 +205,7 @@ int connection_or_create_listener(struct sockaddr_in *bindaddr) {
 }
 
 int connection_or_handle_listener_read(connection_t *conn) {
-  log(LOG_NOTICE,"OR: Received a connection request from a router. Attempting to authenticate.");
+  log(LOG_NOTICE,"OR: Received a connection request. Attempting to authenticate.");
   return connection_handle_listener_read(conn, CONN_TYPE_OR, OR_CONN_STATE_SERVER_AUTH_WAIT);
 }