[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] let purging routerinfos and descriptors take an age argument



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

Modified Files:
	dirserv.c main.c or.h routerlist.c 
Log Message:
let purging routerinfos and descriptors take an age argument


Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- dirserv.c	6 Aug 2004 20:00:14 -0000	1.72
+++ dirserv.c	6 Aug 2004 22:15:25 -0000	1.73
@@ -510,11 +510,11 @@
   return 0;
 }
 
-/** Remove any descriptors from the directory that are more than ROUTER_MAX_AGE
+/** Remove any descriptors from the directory that are more than <b>age</b>
  * seconds old.
  */
 void
-dirserv_remove_old_servers(void)
+dirserv_remove_old_servers(int age)
 {
   int i;
   time_t cutoff;
@@ -522,10 +522,10 @@
   if (!descriptor_list)
     descriptor_list = smartlist_create();
 
-  cutoff = time(NULL) - ROUTER_MAX_AGE;
+  cutoff = time(NULL) - age;
   for (i = 0; i < smartlist_len(descriptor_list); ++i) {
     ent = smartlist_get(descriptor_list, i);
-    if (ent->published < cutoff) {
+    if (ent->published <= cutoff) {
       /* descriptor_list[i] is too old.  Remove it. */
       free_descriptor_entry(ent);
       smartlist_del(descriptor_list, i--);
@@ -556,7 +556,7 @@
 
   if (list_running_servers(&cp))
     return -1;
-  dirserv_remove_old_servers();
+  dirserv_remove_old_servers(ROUTER_MAX_AGE);
   published_on = time(NULL);
   strftime(published, 32, "%Y-%m-%d %H:%M:%S", gmtime(&published_on));
   snprintf(s, maxlen,

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.311
retrieving revision 1.312
diff -u -d -r1.311 -r1.312
--- main.c	6 Aug 2004 08:40:55 -0000	1.311
+++ main.c	6 Aug 2004 22:15:25 -0000	1.312
@@ -544,11 +544,12 @@
       server_is_advertised = 0;
     }
 
-    routerlist_remove_old_routers(); /* purge obsolete entries */
+    /* purge obsolete entries */
+    routerlist_remove_old_routers(ROUTER_MAX_AGE);
 
     if(authdir_mode()) {
       /* We're a directory; dump any old descriptors. */
-      dirserv_remove_old_servers();
+      dirserv_remove_old_servers(ROUTER_MAX_AGE);
     }
     if(server_mode()) {
       /* dirservers try to reconnect, in case connections have failed;

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.396
retrieving revision 1.397
diff -u -d -r1.396 -r1.397
--- or.h	4 Aug 2004 05:10:49 -0000	1.396
+++ or.h	6 Aug 2004 22:15:25 -0000	1.397
@@ -1160,7 +1160,7 @@
 int dirserv_add_descriptor(const char **desc);
 int dirserv_load_from_directory_string(const char *dir);
 void dirserv_free_descriptors();
-void dirserv_remove_old_servers(void);
+void dirserv_remove_old_servers(int age);
 int dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
                                      crypto_pk_env_t *private_key);
 void directory_set_dirty(void);
@@ -1385,7 +1385,7 @@
 void routerinfo_free(routerinfo_t *router);
 routerinfo_t *routerinfo_copy(const routerinfo_t *router);
 void router_mark_as_down(const char *digest);
-void routerlist_remove_old_routers(void);
+void routerlist_remove_old_routers(int age);
 int router_load_routerlist_from_file(char *routerfile, int trusted);
 int router_load_routerlist_from_string(const char *s, int trusted);
 int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- routerlist.c	4 Aug 2004 02:35:06 -0000	1.113
+++ routerlist.c	6 Aug 2004 22:15:25 -0000	1.114
@@ -488,14 +488,14 @@
   return 0;
 }
 
-/** Remove any routers from the routerlist that are more than ROUTER_MAX_AGE
+/** Remove any routers from the routerlist that are more than <b>age</b>
  * seconds old.
  *
  * (This function is just like dirserv_remove_old_servers. One day we should
  * merge them.)
  */
 void
-routerlist_remove_old_routers(void)
+routerlist_remove_old_routers(int age)
 {
   int i;
   time_t cutoff;
@@ -503,10 +503,11 @@
   if (!routerlist)
     return;
 
-  cutoff = time(NULL) - ROUTER_MAX_AGE;
+  cutoff = time(NULL) - age;
   for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
     router = smartlist_get(routerlist->routers, i);
-    if (router->published_on < cutoff &&
+    if (router->published_on <= cutoff &&
+/* XXX008 don't get fooled by cached dir ports */
       !router->dir_port) {
       /* Too old.  Remove it. But never remove dirservers! */
       log_fn(LOG_INFO,"Forgetting obsolete routerinfo for node %s.", router->nickname);