]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
avoid another redundant check
authorRoger Dingledine <arma@torproject.org>
Wed, 13 Apr 2016 07:13:12 +0000 (03:13 -0400)
committerRoger Dingledine <arma@torproject.org>
Mon, 9 May 2016 18:41:54 +0000 (14:41 -0400)
we should avoid launching a consensus fetch if we don't want one,
but if we do end up with an extra one, we should let the other checks
take care of it.

src/or/directory.c
src/or/directory.h
src/or/networkstatus.c
src/or/networkstatus.h

index 2008d07f3e3b24a13899965f4962a6f513cb233a..89b08223d2eb275ef65ff46d4d7936397aa9d812 100644 (file)
@@ -1173,12 +1173,6 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
     return;
   }
 
-  /* ensure we don't make excess connections when we're already downloading
-   * a consensus during bootstrap */
-  if (connection_dir_avoid_extra_connection_for_purpose(dir_purpose)) {
-    return;
-  }
-
   conn = dir_connection_new(tor_addr_family(&addr));
 
   /* set up conn so it's got all the data we need to remember */
@@ -3676,36 +3670,6 @@ connection_dir_finished_flushing(dir_connection_t *conn)
   return 0;
 }
 
-/* Check if we would close excess consensus connections. If we would, any
- * new consensus connection would become excess immediately, so return 1.
- * Otherwise, return 0. */
-int
-connection_dir_avoid_extra_connection_for_purpose(unsigned int purpose)
-{
-  const or_options_t *options = get_options();
-
-  /* We're not interested in connections that aren't fetching a consensus. */
-  if (purpose != DIR_PURPOSE_FETCH_CONSENSUS) {
-    return 0;
-  }
-
-  /* we're only interested in avoiding excess connections if we could
-   * have created any in the first place */
-  if (!networkstatus_consensus_can_use_multiple_directories(options)) {
-    return 0;
-  }
-
-  /* If there are connections downloading a consensus, and we are still
-   * bootstrapping (that is, we have no usable consensus), we can be sure that
-   * any further connections would be excess. */
-  if (networkstatus_consensus_is_downloading_usable_flavor()
-      && networkstatus_consensus_is_bootstrapping(time(NULL))) {
-    return 1;
-  }
-
-  return 0;
-}
-
 /* We just got a new consensus! If there are other in-progress requests
  * for this consensus flavor (for example because we launched several in
  * parallel), cancel them.
@@ -3736,8 +3700,7 @@ connection_dir_close_consensus_fetches(dir_connection_t *except_this_one,
 }
 
 /** Connected handler for directory connections: begin sending data to the
- * server, and return 0, or, if the connection is an excess bootstrap
- * connection, close all excess bootstrap connections.
+ * server, and return 0.
  * Only used when connections don't immediately connect. */
 int
 connection_dir_finished_connecting(dir_connection_t *conn)
index 3254e073d2eb9631393c38397fc30d8958824524..7646cac03f9a3342540d9ae1963f3ab0afbd3530 100644 (file)
@@ -78,7 +78,6 @@ void directory_initiate_command(const tor_addr_t *or_addr, uint16_t or_port,
                                 const char *resource,
                                 const char *payload, size_t payload_len,
                                 time_t if_modified_since);
-int connection_dir_avoid_extra_connection_for_purpose(unsigned int purpose);
 
 #define DSR_HEX       (1<<0)
 #define DSR_BASE64    (1<<1)
index 4a9b36771b0d1089044308289f6fb6f355b10786..3b38c07ea073a21f243181192d69b9399b6786b3 100644 (file)
@@ -1369,15 +1369,6 @@ networkstatus_consensus_is_already_downloading(const char *resource)
   return answer;
 }
 
-/* Is tor currently downloading a consensus of the usable flavor? */
-int
-networkstatus_consensus_is_downloading_usable_flavor(void)
-{
-  const char *resource =
-    networkstatus_get_flavor_name(usable_consensus_flavor());
-  return networkstatus_consensus_is_already_downloading(resource);
-}
-
 /** Given two router status entries for the same router identity, return 1 if
  * if the contents have changed between them. Otherwise, return 0. */
 static int
index e1cd10bf5b989f69791de7adb0217c47d9d7e033..667bc1f0626c6f023645ca29239fd070d5c1b276 100644 (file)
@@ -77,7 +77,6 @@ int networkstatus_consensus_can_use_extra_fallbacks(
                                                 const or_options_t *options);
 int networkstatus_consensus_has_excess_connections(void);
 int networkstatus_consensus_is_already_downloading(const char *resource);
-int networkstatus_consensus_is_downloading_usable_flavor(void);
 
 #define NSSET_FROM_CACHE 1
 #define NSSET_WAS_WAITING_FOR_CERTS 2