aboutsummaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2002-12-31 15:04:14 +0000
committerRoger Dingledine <arma@torproject.org>2002-12-31 15:04:14 +0000
commit9d3e80a589d4c6b25138dd65e2bc3a0a4bcf3d26 (patch)
treebc14eec65977804434c595c11bfa4368979525a0 /src/or/main.c
parent0b717a3e74b46d38ab2432f27c29cc86c2b4f20d (diff)
downloadtor-9d3e80a589d4c6b25138dd65e2bc3a0a4bcf3d26.tar
tor-9d3e80a589d4c6b25138dd65e2bc3a0a4bcf3d26.tar.gz
use a rbtree for replay detection, rather than linear search
when we had lots of new onions coming in, we were using 40% of our time searching through the tracked_onions linked list. svn:r150
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/or/main.c b/src/or/main.c
index c4b25cc16..42976a123 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -376,31 +376,16 @@ int prepare_for_poll(int *timeout) {
for(i=0;i<nfds;i++)
check_conn_marked(i);
-#if 0
- /* check if we need to refill buckets or zero out any per-second stats */
- for(i=0;i<nfds;i++) {
- if(connection_receiver_bucket_should_increase(connection_array[i]) ||
- connection_array[i]->onions_handled_this_second) {
- need_to_wake_soon = 1;
- break;
+ if(now.tv_sec > current_second) { /* the second has already rolled over! */
+ for(i=0;i<nfds;i++) {
+ connection_increment_receiver_bucket(connection_array[i]);
+ connection_array[i]->onions_handled_this_second = 0;
}
+ current_second = now.tv_sec; /* remember which second it is, for next time */
}
-#endif
-// if(need_to_wake_soon) {
- if(now.tv_sec > current_second) { /* the second has already rolled over! */
-// log(LOG_DEBUG,"prepare_for_poll(): The second has rolled over, immediately refilling.");
- for(i=0;i<nfds;i++) {
- connection_increment_receiver_bucket(connection_array[i]);
- connection_array[i]->onions_handled_this_second = 0;
- }
- current_second = now.tv_sec; /* remember which second it is, for next time */
- }
-// } else {
- /* this timeout is definitely sooner than any of the above ones */
- *timeout = 1000 - (now.tv_usec / 1000); /* how many milliseconds til the next second? */
-// }
-// }
+ /* this timeout is definitely sooner than any of the above ones */
+ *timeout = 1000 - (now.tv_usec / 1000); /* how many milliseconds til the next second? */
if(options.LinkPadding) {
/* now check which conn wants to speak soonest */
@@ -668,6 +653,7 @@ int main(int argc, char *argv[]) {
global_role = options.Role; /* assign global_role from options. FIXME: remove from global namespace later. */
crypto_global_init();
+ init_tracked_tree(); /* initialize the replay detection tree */
retval = do_main_loop();
crypto_global_cleanup();