[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [pytorctl/master] Unblocking waits for a response when we error
commit 9de33409bb240d8fe50e135dfb895536dc6a45bd
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Jun 13 09:30:42 2011 -0700
Unblocking waits for a response when we error
When the signal sent by _sendImpl causes the control connection to close we
block indefinitely waiting for a response. For more information see bug 1329.
---
TorCtl.py | 12 +++++++++++-
TorUtil.py | 1 +
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/TorCtl.py b/TorCtl.py
index 2758033..056a65c 100755
--- a/TorCtl.py
+++ b/TorCtl.py
@@ -681,8 +681,18 @@ class Connection:
while 1:
try:
isEvent, reply = self._read_reply()
- except TorCtlClosed:
+ except TorCtlClosed, exc:
plog("NOTICE", "Tor closed control connection. Exiting event thread.")
+
+ # notify anything blocking on a response of the error, for details see:
+ # https://trac.torproject.org/projects/tor/ticket/1329
+ try:
+ self._closedEx = exc
+ cb = self._queue.get(timeout=0)
+ if cb != "CLOSE":
+ cb("EXCEPTION")
+ except Queue.Empty: pass
+
return
except Exception,e:
if not self._closed:
diff --git a/TorUtil.py b/TorUtil.py
index 60d2b2f..29c44bf 100644
--- a/TorUtil.py
+++ b/TorUtil.py
@@ -208,6 +208,7 @@ class BufSock:
s = self._s.recv(128)
except socket.timeout:
if not self._isDone: continue
+ except: s = None
if not s: return None
# XXX: This really does need an exception
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits