[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Cut down a common call to circuit_get_by_conn by about half.
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv27014/src/or
Modified Files:
connection.c
Log Message:
Cut down a common call to circuit_get_by_conn by about half.
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.420
retrieving revision 1.421
diff -u -d -r1.420 -r1.421
--- connection.c 25 Nov 2005 06:43:53 -0000 1.420
+++ connection.c 26 Nov 2005 00:53:51 -0000 1.421
@@ -1582,7 +1582,7 @@
connection_t *
connection_get_by_identity_digest(const char *digest)
{
- int i, n, newer;
+ int i, n, newer, best_has_circ=0, conn_has_circ;
connection_t *conn, *best=NULL;
connection_t **carray;
@@ -1595,6 +1595,7 @@
continue;
if (!best) {
best = conn; /* whatever it is, it's better than nothing. */
+ best_has_circ = (circuit_get_by_conn(best) != NULL);
continue;
}
if (best->state == OR_CONN_STATE_OPEN &&
@@ -1603,10 +1604,13 @@
newer = best->timestamp_created < conn->timestamp_created;
if (conn->is_obsolete && (!best->is_obsolete || !newer))
continue; /* we have something, and it's better than this. */
- if (circuit_get_by_conn(best) && !circuit_get_by_conn(conn))
+ conn_has_circ = (circuit_get_by_conn(conn) != NULL);
+ if (best_has_circ && !conn_has_circ)
continue; /* prefer conns with circuits on them */
- if (newer)
+ if (newer) {
best = conn; /* lastly, prefer newer conns */
+ best_has_circ = conn_has_circ;
+ }
}
return best;
}