[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [chutney/master] Traffic.py: make want_to_write() correct
commit 4f1d926c2b2be807237df8b5d8b24e821b421184
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Tue May 2 20:29:22 2017 -0400
Traffic.py: make want_to_write() correct
The first two parts were correct before: CONNECTING sockets should
check for write, and any socket with a nonempty outbuf should try to
write it. But the third was wrong: only CONNECTED sockets should
try to write because their repetitions and data fields are set --
because on_writable does not actually do anything with those fields
unless the state happens to be CONNECTED.
---
lib/chutney/Traffic.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/chutney/Traffic.py b/lib/chutney/Traffic.py
index e1677fd..03fc3e3 100644
--- a/lib/chutney/Traffic.py
+++ b/lib/chutney/Traffic.py
@@ -258,8 +258,15 @@ class Source(Peer):
return self.want_to_write() # Keep us around for writing if needed
def want_to_write(self):
- return (self.state == self.CONNECTING or len(self.outbuf) > 0 or
- (self.repetitions > 0 and len(self.data) > 0))
+ if self.state == self.CONNECTING:
+ return True
+ if len(self.outbuf) > 0:
+ return True
+ if (self.state == self.CONNECTED and
+ self.repetitions > 0 and
+ len(self.data) > 0):
+ return True
+ return False
def on_writable(self):
"""Invoked when the socket becomes writable.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits