Browse Source

If chutney repeatedly sends no bytes, stop trying

This only seems to happen when all external network interfaces are down.
But Tor should still work using 127.0.0.1.

This requires further investigation.

Investigatory changes for #15353.
teor (Tim Wilson-Brown) 8 years ago
parent
commit
df6ad20619
1 changed files with 11 additions and 2 deletions
  1. 11 2
      lib/chutney/Traffic.py

+ 11 - 2
lib/chutney/Traffic.py

@@ -200,6 +200,7 @@ class Source(Peer):
         self.inbuf = ''
         self.proxy = proxy
         self.repetitions = repetitions
+        self._sent_no_bytes = 0
         # sanity checks
         if len(self.data) == 0:
             self.repetitions = 0
@@ -283,8 +284,16 @@ class Source(Peer):
             raise
         # sometimes, this debug statement prints 0
         # it should print length of the data sent
-        # but the code works regardless of this error
-        debug("successfully sent (bytes=%d)" % n)
+        # but the code works as long as this doesn't keep on happening
+        if n > 0:
+          debug("successfully sent (bytes=%d)" % n)
+          self._sent_no_bytes = 0
+        else:
+          debug("BUG: sent no bytes")
+          self._sent_no_bytes += 1
+          if self._sent_no_bytes >= 10000:
+            print("Send no data %d times. Stalled." % (self._sent_no_bytes))
+            sys.exit(-1)
         self.outbuf = self.outbuf[n:]
         if self.state == self.CONNECTING_THROUGH_PROXY:
             return 1            # Keep us around.