[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] backport the cpu use fixes from main branch to 0.0.9.x
Update of /home2/or/cvsroot/tor/src/or
In directory moria.mit.edu:/home2/arma/work/onion/0091/tor/src/or
Modified Files:
Tag: tor-0_0_9-patches
command.c main.c
Log Message:
backport the cpu use fixes from main branch to 0.0.9.x
Index: command.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/command.c,v
retrieving revision 1.78
retrieving revision 1.78.2.1
diff -u -d -r1.78 -r1.78.2.1
--- command.c 1 Dec 2004 04:55:03 -0000 1.78
+++ command.c 6 Jan 2005 07:40:30 -0000 1.78.2.1
@@ -31,6 +31,7 @@
static void command_process_relay_cell(cell_t *cell, connection_t *conn);
static void command_process_destroy_cell(cell_t *cell, connection_t *conn);
+#ifdef KEEP_TIMING_STATS
/** This is a wrapper function around the actual function that processes the
* <b>cell</b> that just arrived on <b>conn</b>. Increment <b>*time</b>
* by the number of microseconds used by the call to <b>*func(cell, conn)</b>.
@@ -56,6 +57,7 @@
}
*time += time_passed;
}
+#endif
/** Process a <b>cell</b> that was just received on <b>conn</b>. Keep internal
* statistics about how many of each cell we've processed so far
@@ -63,6 +65,7 @@
* process each type of cell.
*/
void command_process_cell(cell_t *cell, connection_t *conn) {
+#ifdef KEEP_TIMING_STATS
/* how many of each cell have we seen so far this second? needs better
* name. */
static int num_create=0, num_created=0, num_relay=0, num_destroy=0;
@@ -87,6 +90,7 @@
/* remember which second it is, for next time */
current_second = now;
}
+#endif
switch (cell->command) {
case CELL_PADDING:
@@ -95,27 +99,43 @@
break;
case CELL_CREATE:
++stats_n_create_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_create;
command_time_process_cell(cell, conn, &create_time,
command_process_create_cell);
+#else
+ command_process_create_cell(cell, conn);
+#endif
break;
case CELL_CREATED:
++stats_n_created_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_created;
command_time_process_cell(cell, conn, &created_time,
command_process_created_cell);
+#else
+ command_process_created_cell(cell, conn);
+#endif
break;
case CELL_RELAY:
++stats_n_relay_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_relay;
command_time_process_cell(cell, conn, &relay_time,
command_process_relay_cell);
+#else
+ command_process_relay_cell(cell, conn);
+#endif
break;
case CELL_DESTROY:
++stats_n_destroy_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_destroy;
command_time_process_cell(cell, conn, &destroy_time,
command_process_destroy_cell);
+#else
+ command_process_destroy_cell(cell, conn);
+#endif
break;
default:
log_fn(LOG_WARN,"Cell of unknown type (%d) received. Dropping.", cell->command);
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.407.2.2
retrieving revision 1.407.2.3
diff -u -d -r1.407.2.2 -r1.407.2.3
--- main.c 3 Jan 2005 21:24:06 -0000 1.407.2.2
+++ main.c 6 Jan 2005 07:40:30 -0000 1.407.2.3
@@ -327,10 +327,10 @@
int retval;
conn = connection_array[i];
- assert_connection_ok(conn, time(NULL));
- assert_all_pending_dns_resolves_ok();
if (!conn->marked_for_close)
return; /* nothing to see here, move along */
+ assert_connection_ok(conn, time(NULL));
+ assert_all_pending_dns_resolves_ok();
log_fn(LOG_INFO,"Cleaning up connection (fd %d).",conn->s);
if (conn->s >= 0 && connection_wants_to_flush(conn)) {