[or-cvs] protect dirservers from overzealous descriptor uploading

Roger Dingledine arma at seul.org
Thu Sep 23 19:58:47 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	dirserv.c 
Log Message:
protect dirservers from overzealous descriptor uploading
wait 10 seconds after directory gets dirty, before regenerating


Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- dirserv.c	21 Sep 2004 18:09:38 -0000	1.79
+++ dirserv.c	23 Sep 2004 19:58:44 -0000	1.80
@@ -11,6 +11,8 @@
 
 /** How far in the future do we allow a router to get? (seconds) */
 #define ROUTER_ALLOW_SKEW (30*60)
+/** How many seconds do we wait before regenerating the directory? */
+#define DIR_REGEN_SLACK_TIME 10
 
 extern or_options_t options; /**< command-line and config-file options */
 
@@ -422,8 +424,12 @@
 void
 directory_set_dirty()
 {
-  the_directory_is_dirty = 1;
-  runningrouters_is_dirty = 1;
+  time_t now = time(NULL);
+
+  if(!the_directory_is_dirty)
+    the_directory_is_dirty = now;
+  if(!runningrouters_is_dirty)
+    runningrouters_is_dirty = now;
 }
 
 /** Load all descriptors from a directory stored in the string
@@ -672,7 +678,8 @@
       return 0;
     }
   }
-  if (the_directory_is_dirty) {
+  if (the_directory_is_dirty &&
+      the_directory_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL)) {
     if (dirserv_regenerate_directory())
       return 0;
   } else {
@@ -792,7 +799,8 @@
  * size of the directory on success, and 0 on failure. */
 size_t dirserv_get_runningrouters(const char **rr)
 {
-  if (runningrouters_is_dirty) {
+  if (runningrouters_is_dirty &&
+      runningrouters_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL)) {
     if(generate_runningrouters(get_identity_key())) {
       log_fn(LOG_ERR, "Couldn't generate running-routers list?");
       return 0;



More information about the tor-commits mailing list