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

[or-cvs] r13058: Change set_current_consensus interface to take a flags varia (in tor/trunk: . src/or)



Author: nickm
Date: 2008-01-07 14:15:34 -0500 (Mon, 07 Jan 2008)
New Revision: 13058

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/dirvote.c
   tor/trunk/src/or/networkstatus.c
   tor/trunk/src/or/or.h
Log:
 r17503@catbus:  nickm | 2008-01-07 14:15:30 -0500
 Change set_current_consensus interface to take a flags variable.  Do not try to fetch certificates until after we have tried loading the fallback consensus.  Should fix bug 583.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r17503] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-01-07 18:54:58 UTC (rev 13057)
+++ tor/trunk/ChangeLog	2008-01-07 19:15:34 UTC (rev 13058)
@@ -33,6 +33,8 @@
       anymore, and we try to upload a hidden service descriptor.
     - Stop leaking one cert per TLS context.  Fixes bug 582.  Bugfix
       on 0.2.0.15-alpha.
+    - Do not try to download missing certificates until we have tried
+      to check our fallback consensus.  Fixes bug 583.
 
   o Minor features (controller):
     - Get NS events working again.  (Patch from tup)

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2008-01-07 18:54:58 UTC (rev 13057)
+++ tor/trunk/src/or/directory.c	2008-01-07 19:15:34 UTC (rev 13058)
@@ -1483,7 +1483,7 @@
     }
     log_info(LD_DIR,"Received consensus directory (size %d) from server "
              "'%s:%d'",(int) body_len, conn->_base.address, conn->_base.port);
-    if ((r=networkstatus_set_current_consensus(body, 0, 0))<0) {
+    if ((r=networkstatus_set_current_consensus(body, 0))<0) {
       log_fn(r<-1?LOG_WARN:LOG_INFO, LD_DIR,
              "Unable to load consensus directory downloaded from "
              "server '%s:%d'", conn->_base.address, conn->_base.port);

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2008-01-07 18:54:58 UTC (rev 13057)
+++ tor/trunk/src/or/dirvote.c	2008-01-07 19:15:34 UTC (rev 13058)
@@ -1850,7 +1850,7 @@
     return -1;
   }
 
-  if (networkstatus_set_current_consensus(pending_consensus_body, 0, 0))
+  if (networkstatus_set_current_consensus(pending_consensus_body, 0))
     log_warn(LD_DIR, "Error publishing consensus");
   else
     log_notice(LD_DIR, "Consensus published.");

Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c	2008-01-07 18:54:58 UTC (rev 13057)
+++ tor/trunk/src/or/networkstatus.c	2008-01-07 19:15:34 UTC (rev 13058)
@@ -163,13 +163,14 @@
   char *s;
   struct stat st;
   or_options_t *options = get_options();
+  const unsigned int flags = NSSET_FROM_CACHE | NSSET_DONT_DOWNLOAD_CERTS;
 
   /* XXXX020 Suppress warnings if cached consensus is bad. */
 
   filename = get_datadir_fname("cached-consensus");
   s = read_file_to_str(filename, RFTS_IGNORE_MISSING, NULL);
   if (s) {
-    if (networkstatus_set_current_consensus(s, 1, 0)) {
+    if (networkstatus_set_current_consensus(s, flags)) {
       log_warn(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
                filename);
     }
@@ -180,7 +181,8 @@
   filename = get_datadir_fname("unverified-consensus");
   s = read_file_to_str(filename, RFTS_IGNORE_MISSING, NULL);
   if (s) {
-    if (networkstatus_set_current_consensus(s, 1, 1)) {
+    if (networkstatus_set_current_consensus(s,
+                                     flags|NSSET_WAS_WAITING_FOR_CERTS)) {
       log_info(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
                filename);
     }
@@ -194,7 +196,7 @@
     s = read_file_to_str(options->FallbackNetworkstatusFile,
                          RFTS_IGNORE_MISSING, NULL);
     if (s) {
-      if (networkstatus_set_current_consensus(s, 1, 1)) {
+      if (networkstatus_set_current_consensus(s, flags)) {
         log_info(LD_FS, "Couldn't load consensus networkstatus from \"%s\"",
                  options->FallbackNetworkstatusFile);
       } else {
@@ -212,6 +214,8 @@
       unnamed_server_map = strmap_new();
   }
 
+  update_certificate_downloads(time(NULL));
+
   routers_update_all_from_networkstatus(time(NULL), 3);
 
   return 0;
@@ -1323,13 +1327,17 @@
  * user, and -2 for more serious problems.
  */
 int
-networkstatus_set_current_consensus(const char *consensus, int from_cache,
-                                    int was_waiting_for_certs)
+networkstatus_set_current_consensus(const char *consensus, unsigned flags)
+
+
 {
   networkstatus_vote_t *c;
   int r, result = -1;
   time_t now = time(NULL);
   char *unverified_fname = NULL, *consensus_fname = NULL;
+  const unsigned from_cache = flags & NSSET_FROM_CACHE;
+  const unsigned was_waiting_for_certs = flags & NSSET_WAS_WAITING_FOR_CERTS;
+  const unsigned dl_certs = !(flags & NSSET_DONT_DOWNLOAD_CERTS);
 
   /* Make sure it's parseable. */
   c = networkstatus_parse_vote_from_string(consensus, NULL, 0);
@@ -1380,7 +1388,8 @@
         if (!from_cache) {
           write_str_to_file(unverified_fname, consensus, 0);
         }
-        authority_certs_fetch_missing(c, now);
+        if (dl_certs)
+          authority_certs_fetch_missing(c, now);
         /* This case is not a success or a failure until we get the certs
          * or fail to get the certs. */
         result = 0;
@@ -1405,7 +1414,7 @@
   }
 
   /* Are we missing any certificates at all? */
-  if (r != 1)
+  if (r != 1 && dl_certs)
     authority_certs_fetch_missing(c, now);
 
   if (control_event_is_interesting(EVENT_NS))
@@ -1486,7 +1495,8 @@
     if (networkstatus_check_consensus_signature(
                                     consensus_waiting_for_certs, 0)>=0) {
       if (!networkstatus_set_current_consensus(
-                                 consensus_waiting_for_certs_body, 0, 1)) {
+                                 consensus_waiting_for_certs_body,
+                                 NSSET_WAS_WAITING_FOR_CERTS)) {
         tor_free(consensus_waiting_for_certs_body);
       }
     }

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-01-07 18:54:58 UTC (rev 13057)
+++ tor/trunk/src/or/or.h	2008-01-07 19:15:34 UTC (rev 13058)
@@ -3366,8 +3366,10 @@
 networkstatus_vote_t *networkstatus_get_latest_consensus(void);
 networkstatus_vote_t *networkstatus_get_live_consensus(time_t now);
 networkstatus_vote_t *networkstatus_get_reasonably_live_consensus(time_t now);
-int networkstatus_set_current_consensus(const char *consensus, int from_cache,
-                                        int was_waiting_for_certs);
+#define NSSET_FROM_CACHE 1
+#define NSSET_WAS_WAITING_FOR_CERTS 2
+#define NSSET_DONT_DOWNLOAD_CERTS 4
+int networkstatus_set_current_consensus(const char *consensus, unsigned flags);
 void networkstatus_note_certs_arrived(void);
 void routers_update_all_from_networkstatus(time_t now, int dir_version);
 void routerstatus_list_update_from_consensus_networkstatus(time_t now);