Quellcode durchsuchen

Refactor bridge download statuses to increment on attempt

We were always incrementing bridge download statuses on each attempt,
but we were using the "increment on failure" functions to do it.
And we never incremented them on failure.

No behaviour change.
teor vor 7 Jahren
Ursprung
Commit
6370fb77c5
1 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. 16 6
      src/or/bridges.c

+ 16 - 6
src/or/bridges.c

@@ -454,6 +454,7 @@ bridge_add_from_config(bridge_line_t *bridge_line)
     b->transport_name = bridge_line->transport_name;
     b->transport_name = bridge_line->transport_name;
   b->fetch_status.schedule = DL_SCHED_BRIDGE;
   b->fetch_status.schedule = DL_SCHED_BRIDGE;
   b->fetch_status.backoff = DL_SCHED_RANDOM_EXPONENTIAL;
   b->fetch_status.backoff = DL_SCHED_RANDOM_EXPONENTIAL;
+  b->fetch_status.increment_on = DL_SCHED_INCREMENT_ATTEMPT;
   b->socks_args = bridge_line->socks_args;
   b->socks_args = bridge_line->socks_args;
   if (!bridge_list)
   if (!bridge_list)
     bridge_list = smartlist_new();
     bridge_list = smartlist_new();
@@ -632,10 +633,13 @@ fetch_bridge_descriptors(const or_options_t *options, time_t now)
         continue;
         continue;
       }
       }
 
 
-      /* schedule another fetch as if this one will fail, in case it does
+      /* schedule the next attempt
-       * (we can't increment after a failure, because sometimes we use the
+       * we can't increment after a failure, because sometimes we use the
-       * bridge authority, and sometimes we use the bridge direct) */
+       * bridge authority, and sometimes we use the bridge direct */
-      download_status_failed(&bridge->fetch_status, 0);
+      download_status_increment_attempt(
+                        &bridge->fetch_status,
+                        safe_str_client(fmt_and_decorate_addr(&bridge->addr)),
+                        now);
 
 
       can_use_bridge_authority = !tor_digest_is_zero(bridge->identity) &&
       can_use_bridge_authority = !tor_digest_is_zero(bridge->identity) &&
                                  num_bridge_auths;
                                  num_bridge_auths;
@@ -793,8 +797,14 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
         download_status_reset(&bridge->fetch_status);
         download_status_reset(&bridge->fetch_status);
         /* We have two quick attempts in the bridge schedule, and then slow
         /* We have two quick attempts in the bridge schedule, and then slow
          * ones */
          * ones */
-        download_status_failed(&bridge->fetch_status, 0);
+        download_status_increment_attempt(
-        download_status_failed(&bridge->fetch_status, 0);
+                        &bridge->fetch_status,
+                        safe_str_client(fmt_and_decorate_addr(&bridge->addr)),
+                        now);
+        download_status_increment_attempt(
+                        &bridge->fetch_status,
+                        safe_str_client(fmt_and_decorate_addr(&bridge->addr)),
+                        now);
       }
       }
 
 
       node = node_get_mutable_by_id(ri->cache_info.identity_digest);
       node = node_get_mutable_by_id(ri->cache_info.identity_digest);