[tor-commits] [sbws/master] circuitbuilder: Stop building the circuit 3 times

juga at torproject.org juga at torproject.org
Fri Feb 15 17:42:48 UTC 2019


commit 4642c1093a3ed73ddea2e71f26458591967a25c2
Author: juga0 <juga at riseup.net>
Date:   Wed Feb 6 16:22:26 2019 +0000

    circuitbuilder: Stop building the circuit 3 times
    
    It is observed that when the circuit can not be built the first
    time, consecutive attemps will also fail.
    The relay will be measured anyway in the next iteration.
    This will also speed up the scanner.
    There is no need to remove the 3 attemps in Destination.
    _perform_usability_test, since the method will be removed in #28897.
    
    Fixes bug #29295. Bugfix v0.1.0.
---
 sbws/lib/circuitbuilder.py | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/sbws/lib/circuitbuilder.py b/sbws/lib/circuitbuilder.py
index 396f238..5eb8a02 100644
--- a/sbws/lib/circuitbuilder.py
+++ b/sbws/lib/circuitbuilder.py
@@ -74,19 +74,13 @@ class CircuitBuilder:
         timeout = self.circuit_timeout
         fp_path = '[' + ' -> '.join([p for p in path]) + ']'
         log.debug('Building %s', fp_path)
-        error = None
-        for _ in range(0, 3):
-            try:
-                circ_id = c.new_circuit(
-                    path, await_build=True, timeout=timeout)
-            except (InvalidRequest, CircuitExtensionFailed,
-                    ProtocolError, Timeout) as e:
-                log.debug(e)
-                error = str(e)
-                continue
-            else:
-                return circ_id, None
-        return None, error
+        try:
+            circ_id = c.new_circuit(
+                path, await_build=True, timeout=timeout)
+        except (InvalidRequest, CircuitExtensionFailed,
+                ProtocolError, Timeout) as e:
+            return None, str(e)
+        return circ_id, None
 
     def __del__(self):
         c = self.controller





More information about the tor-commits mailing list