瀏覽代碼

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) 10 年之前
父節點
當前提交
df6ad20619
共有 1 個文件被更改,包括 11 次插入2 次删除
  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.