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

[or-cvs] Fix at least one overzealous download bug. (tor_malloc_zero...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv13190/src/or

Modified Files:
	directory.c main.c routerlist.c 
Log Message:
Fix at least one overzealous download bug. (tor_malloc_zero new local_routerstatus_t objs); add a pile of logs back in; probe every 10sec; never autolaunch on failure.  Let us see if this works better.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -d -r1.288 -r1.289
--- directory.c	22 Sep 2005 06:34:29 -0000	1.288
+++ directory.c	23 Sep 2005 18:05:13 -0000	1.289
@@ -322,7 +322,7 @@
 {
   /* Try again. No need to increment the failure count for routerdescs, since
    * it's not their fault.*/
-  update_router_descriptor_downloads(time(NULL));
+  /* update_router_descriptor_downloads(time(NULL)); */
 }
 
 /** Helper for directory_initiate_command_(router|trusted_dir): send the
@@ -1598,7 +1598,7 @@
              cp, (int)rs->n_download_failures);
   });
 
-  update_router_descriptor_downloads(time(NULL));
+  /* update_router_descriptor_downloads(time(NULL)); */
 }
 
 /* DOCDOC */

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.556
retrieving revision 1.557
diff -u -d -r1.556 -r1.557
--- main.c	22 Sep 2005 06:34:29 -0000	1.556
+++ main.c	23 Sep 2005 18:05:14 -0000	1.557
@@ -95,7 +95,7 @@
 #define FORCE_REGENERATE_DESCRIPTOR_INTERVAL 18*60*60 /* 18 hours */
 #define CHECK_DESCRIPTOR_INTERVAL 60 /* one minute */
 #define BUF_SHRINK_INTERVAL 60 /* one minute */
-#define DESCRIPTOR_RETRY_INTERVAL 60
+#define DESCRIPTOR_RETRY_INTERVAL 10
 #define DESCRIPTOR_FAILURE_RESET_INTERVAL 60*60
 #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60) /* 20 minutes */
 

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.310
retrieving revision 1.311
diff -u -d -r1.310 -r1.311
--- routerlist.c	23 Sep 2005 17:11:20 -0000	1.310
+++ routerlist.c	23 Sep 2005 18:05:14 -0000	1.311
@@ -2258,7 +2258,7 @@
       if (rs->is_running && ns->is_recent)
         ++n_running;
     }
-    rs_out = tor_malloc(sizeof(local_routerstatus_t));
+    rs_out = tor_malloc_zero(sizeof(local_routerstatus_t));
     memcpy(&rs_out->status, most_recent, sizeof(routerstatus_t));
     if ((rs_old = router_get_combined_status_by_digest(lowest))) {
       rs_out->n_download_failures = rs_old->n_download_failures;
@@ -2368,6 +2368,10 @@
       rs->should_download = 1;
       ++n_downloadable;
     } else {
+      char fp[HEX_DIGEST_LEN+1];
+      base16_encode(fp, HEX_DIGEST_LEN+1, rs->status.identity_digest, DIGEST_LEN);
+      log_fn(LOG_NOTICE, "Not yet ready to download %s (%d more seconds)", fp,
+             (int)(rs->next_attempt_at-now));
       rs->should_download = 0;
     }
   });
@@ -2384,6 +2388,12 @@
                                            downloading, NULL);
     }
   }
+
+  /*
+  log_fn(LOG_NOTICE, "%d downloads already in progress",
+         smartlist_len(downloading));
+  smartlist_sort_strings(downloading);
+  */
   if (n_downloadable) {
     SMARTLIST_FOREACH(downloading, const char *, dl,
     {
@@ -2393,6 +2403,7 @@
       if ((rs = router_get_combined_status_by_digest(d)) && rs->should_download) {
         rs->should_download = 0;
         --n_downloadable;
+        // log_fn(LOG_NOTICE, "%s is in-progress; not fetching", dl);
       }
     });
   }
@@ -2464,6 +2475,7 @@
 update_router_descriptor_downloads(time_t now)
 {
 #define MAX_DL_PER_REQUEST 128
+#define MIN_DL_PER_REQUEST 4
 #define MIN_REQUESTS 3
   smartlist_t *downloadable = NULL;
   int get_all = 0;
@@ -2471,36 +2483,30 @@
   if (!networkstatus_list || smartlist_len(networkstatus_list)<2)
     get_all = 1;
 
-  if (!get_all) {
-    /* Check whether we aren't just better off downloading everybody. */
-    downloadable = router_list_downloadable();
-#if 0
-    /* Actually, asking a single source for "all" routers can be horribly
-     * dangerous. Let's disable this.
-     */
-#define AVG_ROUTER_LEN 1300
-    int excess;
-    excess = smartlist_len(routerstatus_list)-smartlist_len(downloadable);
-    if (smartlist_len(downloadable)*(HEX_DIGEST_LEN+1) >
-        excess*AVG_ROUTER_LEN) {
-      get_all = 1;
-    }
-#endif
-  }
-
   if (get_all) {
     log_fn(LOG_NOTICE, "Launching request for all routers");
     directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,"all.z",1);
-  } else if (smartlist_len(downloadable)) {
+    return;
+  }
+
+  downloadable = router_list_downloadable();
+  if (smartlist_len(downloadable)) {
     int i, j, n, n_per_request;
     size_t r_len = MAX_DL_PER_REQUEST*(HEX_DIGEST_LEN+1)+16;
     char *resource = tor_malloc(r_len);
+
     n = smartlist_len(downloadable);
+    /*
     n_per_request = (n+MIN_REQUESTS-1) / MIN_REQUESTS;
     if (n_per_request > MAX_DL_PER_REQUEST)
       n_per_request = MAX_DL_PER_REQUEST;
-    if (n_per_request < 1)
-      n_per_request = 1;
+    if (n_per_request < MIN_DL_PER_REQUEST)
+      n_per_request = MIN_DL_PER_REQUEST;
+    */
+    n_per_request = MAX_DL_PER_REQUEST;
+    log_fn(LOG_NOTICE, "Launching %d request%s for %d router%s, %d at a time",
+           (n+n_per_request-1)/n_per_request, n>n_per_request?"s":"",
+           n, n>1?"s":"", n_per_request);
     for (i=0; i < n; i += n_per_request) {
       char *cp = resource;
       memcpy(resource, "fp/", 3);
@@ -2511,18 +2517,14 @@
         *cp++ = '+';
       }
       memcpy(cp-1, ".z", 3);
-      log_fn(LOG_NOTICE, "Launching request for %d routers", j-i);
       directory_get_from_dirserver(DIR_PURPOSE_FETCH_SERVERDESC,resource,1);
     }
     tor_free(resource);
   } else {
-    log_fn(LOG_DEBUG, "No routers to download.");
-  }
-
-  if (downloadable) {
-    SMARTLIST_FOREACH(downloadable, char *, c, tor_free(c));
-    smartlist_free(downloadable);
+    log_fn(LOG_NOTICE, "No routers to download.");
   }
+  SMARTLIST_FOREACH(downloadable, char *, c, tor_free(c));
+  smartlist_free(downloadable);
 }
 
 /** Return true iff we have enough networkstatus and router information to