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

[or-cvs] r9190: Stop counting 503s against the total number of failures allo (in tor/trunk: . doc src/or)



Author: nickm
Date: 2006-12-24 21:47:37 -0500 (Sun, 24 Dec 2006)
New Revision: 9190

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/main.c
Log:
 r11711@Kushana:  nickm | 2006-12-24 21:42:57 -0500
 Stop counting 503s against the total number of failures allowed for a download.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11711] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-24 19:00:16 UTC (rev 9189)
+++ tor/trunk/ChangeLog	2006-12-25 02:47:37 UTC (rev 9190)
@@ -59,6 +59,9 @@
       secret_onion_key in 0.0.8pre1.
     - We no longer require unrecognized directory entries to be preceded by
       "opt".
+    - When we get a 503 from a directory, and we're not a server, we don't
+      count the failure against the total number of failures allowed for the
+      thing we're trying to download.
 
   o Security bugfixes:
     - Stop sending the HttpProxyAuthenticator string to directory

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-12-24 19:00:16 UTC (rev 9189)
+++ tor/trunk/doc/TODO	2006-12-25 02:47:37 UTC (rev 9190)
@@ -131,9 +131,10 @@
   - Critical but minor bugs, backport candidates.
     - support dir 503s better
       o clients don't log as loudly when they receive them
-N     - they don't count toward the 3-strikes rule
-        - should there be some threshold of 503's after which we give up?
-        - Delay when we get a lot of 503s?
+      o they don't count toward the 3-strikes rule
+        D But eventually, we give up after getting a lot of 503s.
+N       - Delay when we get a lot of 503s, rather than punting onto the
+          servers that have given us 503s?
       o split "router is down" from "dirport shouldn't be tried for a while"?
         We want a field to hold "when did we last get a 503 from this
         directory server."  Probably, it should go in local_routerstatus_t,

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2006-12-24 19:00:16 UTC (rev 9189)
+++ tor/trunk/src/or/directory.c	2006-12-25 02:47:37 UTC (rev 9190)
@@ -47,10 +47,11 @@
 static char *http_get_header(const char *headers, const char *which);
 static void http_set_address_origin(const char *headers, connection_t *conn);
 static void connection_dir_download_networkstatus_failed(
-                                                      dir_connection_t *conn);
+                                      dir_connection_t *conn, int status);
 static void connection_dir_download_routerdesc_failed(dir_connection_t *conn);
-static void dir_networkstatus_download_failed(smartlist_t *failed);
-static void dir_routerdesc_download_failed(smartlist_t *failed);
+static void dir_networkstatus_download_failed(smartlist_t *failed, int status);
+static void dir_routerdesc_download_failed(smartlist_t *failed,
+                                           int status_code);
 static void note_request(const char *key, size_t bytes);
 
 /********* START VARIABLES **********/
@@ -284,8 +285,9 @@
                              payload, payload_len);
 }
 
-/** Called when we are unable to complete the client's request to a
- * directory server: Mark the router as down and try again if possible.
+/** Called when we are unable to complete the client's request to a directory
+ * server due to a network error: Mark the router as down and try again if
+ * possible.
  */
 void
 connection_dir_request_failed(dir_connection_t *conn)
@@ -302,7 +304,7 @@
   } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
     log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
              conn->_base.address);
-    connection_dir_download_networkstatus_failed(conn);
+    connection_dir_download_networkstatus_failed(conn, -1);
   } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC) {
     log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
              conn->_base.address);
@@ -315,7 +317,8 @@
  * retry the fetch now, later, or never.
  */
 static void
-connection_dir_download_networkstatus_failed(dir_connection_t *conn)
+connection_dir_download_networkstatus_failed(dir_connection_t *conn,
+                                             int status)
 {
   if (!conn->requested_resource) {
     /* We never reached directory_send_command, which means that we never
@@ -324,7 +327,9 @@
     return;
   }
   if (!strcmpstart(conn->requested_resource, "all")) {
-    /* We're a non-authoritative directory cache; try again. */
+    /* We're a non-authoritative directory cache; try again. Ignore status
+     * code, since we don't want to keep trying forever in a tight loop
+     * if all the authorities are shutting us out. */
     smartlist_t *trusted_dirs = router_get_trusted_dir_servers();
     SMARTLIST_FOREACH(trusted_dirs, trusted_dir_server_t *, ds,
                       ++ds->n_networkstatus_failures);
@@ -337,7 +342,7 @@
     dir_split_resource_into_fingerprints(conn->requested_resource+3,
                                          failed, NULL, 0, 0);
     if (smartlist_len(failed)) {
-      dir_networkstatus_download_failed(failed);
+      dir_networkstatus_download_failed(failed, status);
       SMARTLIST_FOREACH(failed, char *, cp, tor_free(cp));
     }
     smartlist_free(failed);
@@ -1050,7 +1055,7 @@
            status_code, escaped(reason), conn->_base.address,
            conn->_base.port, conn->requested_resource);
       tor_free(body); tor_free(headers); tor_free(reason);
-      connection_dir_download_networkstatus_failed(conn);
+      connection_dir_download_networkstatus_failed(conn, status_code);
       return -1;
     }
     note_request(was_compressed?"dl/status.z":"dl/status", orig_len);
@@ -1096,7 +1101,7 @@
     directory_info_has_arrived(time(NULL), 0);
     if (which) {
       if (smartlist_len(which)) {
-        dir_networkstatus_download_failed(which);
+        dir_networkstatus_download_failed(which, status_code);
       }
       SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
       smartlist_free(which);
@@ -1129,7 +1134,7 @@
       if (!which) {
         connection_dir_download_routerdesc_failed(conn);
       } else {
-        dir_routerdesc_download_failed(which);
+        dir_routerdesc_download_failed(which, status_code);
         SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
         smartlist_free(which);
       }
@@ -1152,7 +1157,7 @@
                n_asked_for-smartlist_len(which), n_asked_for,
                conn->_base.address, (int)conn->_base.port);
       if (smartlist_len(which)) {
-        dir_routerdesc_download_failed(which);
+        dir_routerdesc_download_failed(which, status_code);
       }
       SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
       smartlist_free(which);
@@ -1930,10 +1935,12 @@
 
 /** Called when one or more networkstatus fetches have failed (with uppercase
  * fingerprints listed in <b>failed</>).  Mark those fingerprints as having
- * failed once. */
+ * failed once, unless they failed with status code 503. */
 static void
-dir_networkstatus_download_failed(smartlist_t *failed)
+dir_networkstatus_download_failed(smartlist_t *failed, int status)
 {
+  if (status == 503)
+    return;
   SMARTLIST_FOREACH(failed, const char *, fp,
   {
     char digest[DIGEST_LEN];
@@ -1949,7 +1956,7 @@
 /** Called when one or more routerdesc fetches have failed (with uppercase
  * fingerprints listed in <b>failed</b>). */
 static void
-dir_routerdesc_download_failed(smartlist_t *failed)
+dir_routerdesc_download_failed(smartlist_t *failed, int status_code)
 {
   char digest[DIGEST_LEN];
   local_routerstatus_t *rs;
@@ -1961,9 +1968,11 @@
     rs = router_get_combined_status_by_digest(digest);
     if (!rs || rs->n_download_failures >= MAX_ROUTERDESC_DOWNLOAD_FAILURES)
       continue;
-    ++rs->n_download_failures;
+    if (status_code != 503 || server)
+      ++rs->n_download_failures;
     if (server) {
       switch (rs->n_download_failures) {
+        case 0: rs->next_attempt_at = 0; break;
         case 1: rs->next_attempt_at = 0; break;
         case 2: rs->next_attempt_at = 0; break;
         case 3: rs->next_attempt_at = now+60; break;
@@ -1975,6 +1984,7 @@
       }
     } else {
       switch (rs->n_download_failures) {
+        case 0: rs->next_attempt_at = 0; break;
         case 1: rs->next_attempt_at = 0; break;
         case 2: rs->next_attempt_at = now+60; break;
         case 3: rs->next_attempt_at = now+60*5; break;

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2006-12-24 19:00:16 UTC (rev 9189)
+++ tor/trunk/src/or/main.c	2006-12-25 02:47:37 UTC (rev 9190)
@@ -2064,8 +2064,7 @@
   smartlist_free(sl);
 
   /* Allocate a string for the NT service command line */
-  cmdlen = strlen(tor_exe)+ strlen(" --nt-service -f ")
-    + strlen(options) + 32;
+  cmdlen = strlen(tor_exe) + strlen(options) + 32;
   command = tor_malloc(cmdlen);
 
   /* Format the service command */