[or-cvs] stop fetching descriptors if we"re not a dir mirror and we

arma at seul.org arma at seul.org
Tue May 30 06:19:08 UTC 2006


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

Modified Files:
	circuituse.c or.h rephist.c routerlist.c 
Log Message:
stop fetching descriptors if we're not a dir mirror and we
haven't tried to establish any circuits lately.


Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -p -d -r1.125 -r1.126
--- circuituse.c	18 Apr 2006 03:07:24 -0000	1.125
+++ circuituse.c	30 May 2006 06:19:06 -0000	1.126
@@ -542,8 +542,8 @@ circuit_about_to_close_connection(connec
   } /* end switch */
 }
 
-/** Find each circuit that has been dirty for too long, and has
- * no streams on it: mark it for close.
+/** Find each circuit that has been unused for too long, or dirty
+ * for too long and has no streams on it: mark it for close.
  */
 static void
 circuit_expire_old_circuits(time_t now)

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.831
retrieving revision 1.832
diff -u -p -d -r1.831 -r1.832
--- or.h	29 Apr 2006 18:42:26 -0000	1.831
+++ or.h	30 May 2006 06:19:06 -0000	1.832
@@ -473,6 +473,7 @@ typedef enum {
 #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
 #define RESOLVED_TYPE_ERROR 0xF1
 
+/* XXX We should document the meaning of these. */
 #define END_CIRC_AT_ORIGIN           -1
 #define _END_CIRC_REASON_MIN            0
 #define END_CIRC_REASON_NONE            0
@@ -2084,6 +2085,8 @@ void rep_hist_note_bytes_read(int num_by
 void rep_hist_note_bytes_written(int num_bytes, time_t when);
 int rep_hist_bandwidth_assess(void);
 char *rep_hist_get_bandwidth_lines(void);
+void rep_hist_update_state(or_state_t *state);
+int rep_hist_load_state(or_state_t *state, char **err);
 void rep_history_clean(time_t before);
 
 void rep_hist_note_used_port(uint16_t port, time_t now);
@@ -2094,8 +2097,7 @@ void rep_hist_note_used_internal(time_t 
 int rep_hist_get_predicted_internal(time_t now, int *need_uptime,
                                     int *need_capacity);
 
-void rep_hist_update_state(or_state_t *state);
-int rep_hist_load_state(or_state_t *state, char **err);
+int rep_hist_circbuilding_dormant(void);
 
 void rep_hist_free_all(void);
 

Index: rephist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/rephist.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -p -d -r1.85 -r1.86
--- rephist.c	18 Apr 2006 03:07:24 -0000	1.85
+++ rephist.c	30 May 2006 06:19:06 -0000	1.86
@@ -751,6 +751,8 @@ rep_hist_load_state(or_state_t *state, c
   return 0;
 }
 
+/*********************************************************************/
+
 /** A list of port numbers that have been used recently. */
 static smartlist_t *predicted_ports_list=NULL;
 /** The corresponding most recently used time for each port. */
@@ -912,6 +914,15 @@ rep_hist_get_predicted_internal(time_t n
   return 1;
 }
 
+/** Return 1 if we have no need for circuits currently, else return 0. */
+int
+rep_hist_circbuilding_dormant(void)
+{
+  if (predicted_ports_list || predicted_internal_time)
+    return 0; /* nothing used lately. */
+  return 1;
+}
+
 /** Free all storage held by the OR/link history caches, by the
  * bandwidth history arrays, or by the port history. */
 void

Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.513
retrieving revision 1.514
diff -u -p -d -r1.513 -r1.514
--- routerlist.c	30 May 2006 06:11:36 -0000	1.513
+++ routerlist.c	30 May 2006 06:19:06 -0000	1.514
@@ -3435,6 +3435,12 @@ update_router_descriptor_client_download
              "Called router_descriptor_client_downloads() on a dir mirror?");
   }
 
+  if (rep_hist_circbuilding_dormant()) {
+    log_info(LD_CIRC, "Skipping descriptor downloads: we haven't need "
+             "any circuits lately.");
+    return;
+  }
+
   /* XXX here's another magic 2 that probably should be replaced
    * by <= smartlist_len(trusted_dir_servers)/2
    * or by a function returning same.  -- weasel */



More information about the tor-commits mailing list