[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] fix many bugs in package_window handling



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	circuit.c connection.c connection_edge.c connection_or.c 
Log Message:
fix many bugs in package_window handling


Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- circuit.c	24 Jun 2003 05:17:48 -0000	1.54
+++ circuit.c	3 Jul 2003 03:40:47 -0000	1.55
@@ -405,9 +405,10 @@
        (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: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- connection.c	25 Jun 2003 00:31:41 -0000	1.69
+++ connection.c	3 Jul 2003 03:40:47 -0000	1.70
@@ -550,12 +550,20 @@
 
   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 @@
 
   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 @@
     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: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- connection_edge.c	28 Jun 2003 06:17:01 -0000	1.14
+++ connection_edge.c	3 Jul 2003 03:40:47 -0000	1.15
@@ -50,7 +50,6 @@
     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 @@
         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: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- connection_or.c	25 Jun 2003 00:31:41 -0000	1.34
+++ connection_or.c	3 Jul 2003 03:40:47 -0000	1.35
@@ -205,7 +205,7 @@
 }
 
 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);
 }