]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r19202@catbus: nickm | 2008-04-04 17:18:47 -0400
authorNick Mathewson <nickm@torproject.org>
Fri, 4 Apr 2008 21:18:56 +0000 (21:18 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 4 Apr 2008 21:18:56 +0000 (21:18 +0000)
 Make last_served_at optional; make last_listed_as_valid_until take account (partially) of v2 statuses.

svn:r14299

src/or/dirserv.c
src/or/networkstatus.c
src/or/or.h

index aa4d8b717e3732b2a0b54334f10cf45431fb863c..63bc2b0e28db2240fa73a48cd8d4fa525b9bb10e 100644 (file)
@@ -2939,7 +2939,9 @@ connection_dirserv_finish_spooling(dir_connection_t *conn)
 static int
 connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn)
 {
+#ifdef TRACK_SERVED_TIME
   time_t now = time(NULL);
+#endif
   int by_fp = (conn->dir_spool_src == DIR_SPOOL_SERVER_BY_FP ||
                conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP);
   int extra = (conn->dir_spool_src == DIR_SPOOL_EXTRA_BY_FP ||
@@ -2967,7 +2969,9 @@ connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn)
        * unknown bridge descriptor has shown up between then and now. */
       continue;
     }
+#ifdef TRACK_SERVED_TIME
     sd->last_served_at = now;
+#endif
     body = signed_descriptor_get_body(sd);
     if (conn->zlib_state) {
       int last = ! smartlist_len(conn->fingerprint_stack);
index 0cc1b210a3a3e55d3f670f16919408ce76fc21dc..4ed4993b51cfc14116b12b7318f0dd6e9f5b8fdd 100644 (file)
@@ -697,11 +697,24 @@ router_set_networkstatus_v2(const char *s, time_t arrived_at,
   if (!found)
     smartlist_add(networkstatus_v2_list, ns);
 
-  SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
+/*XXXX021 magic. */
+/*DOCDOC */
+#define V2_NETWORKSTATUS_LIFETIME (3*60*60)
+
+  {
+    time_t live_until = ns->published_on + V2_NETWORKSTATUS_LIFETIME;
+    SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
     {
-      if (!router_get_by_descriptor_digest(rs->descriptor_digest))
+      signed_descriptor_t *sd =
+        router_get_by_descriptor_digest(rs->descriptor_digest);
+      if (sd) {
+        if (sd->last_listed_as_valid_until < live_until)
+          sd->last_listed_as_valid_until = live_until;
+      } else {
         rs->need_to_mirror = 1;
+      }
     });
+  }
 
   log_info(LD_DIR, "Setting networkstatus %s %s (published %s)",
            source == NS_FROM_CACHE?"cached from":
@@ -1286,6 +1299,7 @@ notify_control_networkstatus_changed(const networkstatus_t *old_c,
   if (old_remain)
     rs_old = smartlist_get(old_c->routerstatus_list, idx);
 
+  /* XXXX021 candidate for a foreach_matched macro. */
   SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new,
   {
     if (!old_remain) {
@@ -1323,6 +1337,7 @@ networkstatus_copy_old_consensus_info(networkstatus_t *new_c,
     return;
 
   rs_old = smartlist_get(old_c->routerstatus_list, idx);
+  /* XXXX021 candidate for a FOREACH_MATCHED macro. */
   SMARTLIST_FOREACH(new_c->routerstatus_list, routerstatus_t *, rs_new,
   {
     int r;
@@ -1709,6 +1724,7 @@ routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
   idx = 0;
   rs = smartlist_get(ns->routerstatus_list, idx);
 
+  /* Candidate for a FOREACH_MATCHED macro.XXX021 */
   SMARTLIST_FOREACH(routers, routerinfo_t *, router,
   {
     const char *digest = router->cache_info.identity_digest;
index e4766ba145bcdfe0fc98e7490ef9783fee3b3280..71397597e1173944a434b0e3605d5648f3f9f307 100644 (file)
@@ -1219,10 +1219,14 @@ typedef struct signed_descriptor_t {
    * routerlist->old_routers? -1 for none. */
   int routerlist_index;
   /** The valid-until time of the most recent consensus that listed this
-   * descriptor.  0 for "never listed in a consensus, so far as we know." */
+   * descriptor, or a bit after the publication time of the most recent v2
+   * networkstatus that listed it.  0 for "never listed in a consensus or
+   * status, so far as we know." */
   time_t last_listed_as_valid_until;
+#ifdef TRACK_SERVED_TIME
   /** DOCDOC */
   time_t last_served_at; /*XXXX021 remove if not useful. */
+#endif
   /* If true, we do not ever try to save this object in the cache. */
   unsigned int do_not_cache : 1;
   /* If true, this item is meant to represent an extrainfo. */