[or-cvs] r15185: backport r14329 and r14334: Make relay cells written on a co (in tor/branches/tor-0_2_0-patches: . doc src/or)

arma at seul.org arma at seul.org
Fri Jun 13 05:12:28 UTC 2008


Author: arma
Date: 2008-06-13 01:12:27 -0400 (Fri, 13 Jun 2008)
New Revision: 15185

Modified:
   tor/branches/tor-0_2_0-patches/ChangeLog
   tor/branches/tor-0_2_0-patches/doc/TODO.020
   tor/branches/tor-0_2_0-patches/src/or/connection_or.c
   tor/branches/tor-0_2_0-patches/src/or/or.h
   tor/branches/tor-0_2_0-patches/src/or/relay.c
Log:
backport r14329 and r14334:
Make relay cells written on a connection count as non-padding when
tracking how long a connection has been in use. Bugfix on
0.2.0.1-alpha. Spotted by lodger.


Modified: tor/branches/tor-0_2_0-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_2_0-patches/ChangeLog	2008-06-13 04:36:30 UTC (rev 15184)
+++ tor/branches/tor-0_2_0-patches/ChangeLog	2008-06-13 05:12:27 UTC (rev 15185)
@@ -30,6 +30,9 @@
       bug 688, reported by mfr.
     - When we haven't had any application requests lately, don't bother
       logging that we have expired a bunch of descriptors.
+    - Make relay cells written on a connection count as non-padding when
+      tracking how long a connection has been in use. Bugfix on
+      0.2.0.1-alpha. Spotted by lodger.
     - Fix unit tests in 0.2.0.27-rc.
     - Fix compile on Windows.
 

Modified: tor/branches/tor-0_2_0-patches/doc/TODO.020
===================================================================
--- tor/branches/tor-0_2_0-patches/doc/TODO.020	2008-06-13 04:36:30 UTC (rev 15184)
+++ tor/branches/tor-0_2_0-patches/doc/TODO.020	2008-06-13 05:12:27 UTC (rev 15185)
@@ -16,7 +16,7 @@
   o r14205: free authority certs on exit.
   o r14212: free static hashtables and log mutex on exit.
   o r14214: don't read torrc when all we do is --hash-password
-  - r14329: update last_added_nonpadding for relay cells.
+  o r14329: update last_added_nonpadding for relay cells.
   - r14247: tor-spec and dir-spec updates [just backport the whole files]
 
 Backport for 0.2.0 once better tested:

Modified: tor/branches/tor-0_2_0-patches/src/or/connection_or.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/connection_or.c	2008-06-13 04:36:30 UTC (rev 15184)
+++ tor/branches/tor-0_2_0-patches/src/or/connection_or.c	2008-06-13 05:12:27 UTC (rev 15185)
@@ -285,13 +285,15 @@
 connection_or_flushed_some(or_connection_t *conn)
 {
   size_t datalen = buf_datalen(conn->_base.outbuf);
+  time_t now = time(NULL);
   /* If we're under the low water mark, add cells until we're just over the
    * high water mark. */
   if (datalen < OR_CONN_LOWWATER) {
     ssize_t n = (OR_CONN_HIGHWATER - datalen + CELL_NETWORK_SIZE-1)
       / CELL_NETWORK_SIZE;
     while (conn->active_circuits && n > 0) {
-      int flushed = connection_or_flush_from_first_active_circuit(conn, 1);
+      int flushed;
+      flushed = connection_or_flush_from_first_active_circuit(conn, 1, now);
       n -= flushed;
     }
   }

Modified: tor/branches/tor-0_2_0-patches/src/or/or.h
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/or.h	2008-06-13 04:36:30 UTC (rev 15184)
+++ tor/branches/tor-0_2_0-patches/src/or/or.h	2008-06-13 05:12:27 UTC (rev 15185)
@@ -3557,7 +3557,7 @@
                                   cell_t *cell, int direction);
 void connection_or_unlink_all_active_circs(or_connection_t *conn);
 int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
-                                                  int max);
+                                                  int max, time_t now);
 void assert_active_circuits_ok(or_connection_t *orconn);
 void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn);
 void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn);

Modified: tor/branches/tor-0_2_0-patches/src/or/relay.c
===================================================================
--- tor/branches/tor-0_2_0-patches/src/or/relay.c	2008-06-13 04:36:30 UTC (rev 15184)
+++ tor/branches/tor-0_2_0-patches/src/or/relay.c	2008-06-13 05:12:27 UTC (rev 15185)
@@ -1833,7 +1833,8 @@
  * <b>conn</b>-&gt;outbuf.  Return the number of cells written.  Advance
  * the active circuit pointer to the next active circuit in the ring. */
 int
-connection_or_flush_from_first_active_circuit(or_connection_t *conn, int max)
+connection_or_flush_from_first_active_circuit(or_connection_t *conn,
+                                              int max, time_t now)
 {
   int n_flushed;
   cell_queue_t *queue;
@@ -1866,7 +1867,7 @@
        * for us.
        */
       assert_active_circuits_ok_paranoid(conn);
-      return n_flushed;
+      goto done;
     }
   }
   tor_assert(*next_circ_on_conn_p(circ,conn));
@@ -1883,6 +1884,9 @@
     log_debug(LD_GENERAL, "Made a circuit inactive.");
     make_circuit_inactive_on_conn(circ, conn);
   }
+ done:
+  if (n_flushed)
+    conn->timestamp_last_added_nonpadding = now;
   return n_flushed;
 }
 
@@ -1927,7 +1931,7 @@
      * get called, and we can start putting more data onto the buffer then.
      */
     log_debug(LD_GENERAL, "Primed a buffer.");
-    connection_or_flush_from_first_active_circuit(orconn, 1);
+    connection_or_flush_from_first_active_circuit(orconn, 1, time(NULL));
   }
 }
 



More information about the tor-commits mailing list