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

[or-cvs] bugfix: decrement OR connections from global_bucket too



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

Modified Files:
	connection.c main.c or.h 
Log Message:
bugfix: decrement OR connections from global_bucket too
bugfix: don't return immediately for has_pending_tls_data unless
        the conn is allowed to read


Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- connection.c	14 Mar 2004 16:00:52 -0000	1.182
+++ connection.c	14 Mar 2004 17:06:29 -0000	1.183
@@ -494,7 +494,7 @@
 /* keep a timeval to know when time has passed enough to refill buckets */
 static struct timeval current_time;
 
-void connection_bucket_init() {
+void connection_bucket_init(void) {
   tor_gettimeofday(&current_time);
   global_read_bucket = options.BandwidthBurst; /* start it at max traffic */
 }
@@ -533,6 +533,7 @@
            conn->state != OR_CONN_STATE_OPEN ||
            conn->receiver_bucket > 0)) {
       /* and either a non-cell conn or a cell conn with non-empty bucket */
+      log_fn(LOG_DEBUG,"waking up conn (fd %d)",conn->s);
       conn->wants_to_read = 0;
       connection_start_reading(conn);
       if(conn->wants_to_write == 1) {
@@ -600,8 +601,10 @@
   at_most = connection_bucket_read_limit(conn);
 
   if(connection_speaks_cells(conn) && conn->state != OR_CONN_STATE_CONNECTING) {
-    if(conn->state == OR_CONN_STATE_HANDSHAKING)
+    if(conn->state == OR_CONN_STATE_HANDSHAKING) {
+      /* continue handshaking even if global token bucket is empty */
       return connection_tls_continue_handshake(conn);
+    }
 
     /* else open, or closing */
     result = read_to_buf_tls(conn->tls, at_most, conn->inbuf);
@@ -616,7 +619,8 @@
         return 0;
       case TOR_TLS_WANTREAD: /* we're already reading */
       case TOR_TLS_DONE: /* no data read, so nothing to process */
-        return 0;
+        result = 0;
+        break; /* so we call bucket_decrement below */
     }
   } else {
     result = read_to_buf(conn->s, at_most, conn->inbuf,

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- main.c	14 Mar 2004 16:00:52 -0000	1.202
+++ main.c	14 Mar 2004 17:06:29 -0000	1.203
@@ -421,7 +421,8 @@
 
   for(i=0;i<nfds;i++) {
     conn = connection_array[i];
-    if(connection_has_pending_tls_data(conn)) {
+    if(connection_has_pending_tls_data(conn) &&
+       connection_is_reading(conn)) {
       log_fn(LOG_DEBUG,"sock %d has pending bytes.",conn->s);
       return 0; /* has pending bytes to read; don't let poll wait. */
     }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -d -r1.252 -r1.253
--- or.h	14 Mar 2004 16:00:52 -0000	1.252
+++ or.h	14 Mar 2004 17:06:29 -0000	1.253
@@ -693,6 +693,9 @@
 int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port);
 int retry_all_connections(void);
 
+void connection_bucket_init(void);
+void connection_bucket_refill(struct timeval *now);
+
 int connection_handle_read(connection_t *conn);
 int connection_read_to_buf(connection_t *conn);