From 95d0e68cf26459890e94077cd3b389f285987532 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Thu, 3 Dec 2015 16:22:03 -0600 Subject: [PATCH] transit: avoid near-infinite loop upon connector error Now we will never try any hint more than once. Previously we'd hit the relay hint over and over until the timeout fired. --- src/wormhole/blocking/transit.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wormhole/blocking/transit.py b/src/wormhole/blocking/transit.py index d0b728d..41c4c45 100644 --- a/src/wormhole/blocking/transit.py +++ b/src/wormhole/blocking/transit.py @@ -348,12 +348,18 @@ class Common: def _start_outbound(self): self._active_connectors = set(self._their_direct_hints) + self._attempted_connectors = set() for hint in self._their_direct_hints: self._start_connector(hint) if not self._their_direct_hints: self._start_relay_connectors() def _start_connector(self, hint, is_relay=False): + # Don't try any hint more than once. If all hints fail, we'll + # eventually timeout. We make no attempt to fail any faster. + if hint in self._attempted_connectors: + return + self._attempted_connectors.add(hint) description = "->%s" % (hint,) if is_relay: description = "->relay:%s" % (hint,)