[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r14334: Do a slightly better fix for r14329: don't call time() quite (in tor/trunk: . doc src/or)
Author: nickm
Date: 2008-04-09 14:44:50 -0400 (Wed, 09 Apr 2008)
New Revision: 14334
Modified:
tor/trunk/
tor/trunk/doc/TODO
tor/trunk/src/or/connection_or.c
tor/trunk/src/or/or.h
tor/trunk/src/or/relay.c
Log:
r19273@catbus: nickm | 2008-04-09 14:44:23 -0400
Do a slightly better fix for r14329: don't call time() quite so much. Also note the time(NULL) hack we wanted to do in the TODO.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r19273] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO 2008-04-09 18:24:55 UTC (rev 14333)
+++ tor/trunk/doc/TODO 2008-04-09 18:44:50 UTC (rev 14334)
@@ -323,6 +323,8 @@
- Router_choose_random_node() has a big pile of args. make it "flags".
- Streamline how we pick entry nodes: Make choose_random_entry() have
less magic and less control logic.
+ - Don't call time(NULL) so much; instead have a static time_t field
+ that gets updated only a handful of times per second.
- Make Tor able to chroot itself
o allow it to load an entire config file from control interface
Modified: tor/trunk/src/or/connection_or.c
===================================================================
--- tor/trunk/src/or/connection_or.c 2008-04-09 18:24:55 UTC (rev 14333)
+++ tor/trunk/src/or/connection_or.c 2008-04-09 18:44:50 UTC (rev 14334)
@@ -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/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2008-04-09 18:24:55 UTC (rev 14333)
+++ tor/trunk/src/or/or.h 2008-04-09 18:44:50 UTC (rev 14334)
@@ -3560,7 +3560,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/trunk/src/or/relay.c
===================================================================
--- tor/trunk/src/or/relay.c 2008-04-09 18:24:55 UTC (rev 14333)
+++ tor/trunk/src/or/relay.c 2008-04-09 18:44:50 UTC (rev 14334)
@@ -1835,7 +1835,8 @@
* <b>conn</b>->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;
@@ -1887,7 +1888,7 @@
}
done:
if (n_flushed)
- conn->timestamp_last_added_nonpadding = time(NULL);
+ conn->timestamp_last_added_nonpadding = now;
return n_flushed;
}
@@ -1932,7 +1933,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));
}
}