[or-cvs] r20502: {torctl} Fix an exception crash on stream closing and kill a WARN. (torctl/trunk/python/TorCtl)

mikeperry at seul.org mikeperry at seul.org
Tue Sep 8 19:31:54 UTC 2009


Author: mikeperry
Date: 2009-09-08 15:31:53 -0400 (Tue, 08 Sep 2009)
New Revision: 20502

Modified:
   torctl/trunk/python/TorCtl/PathSupport.py
   torctl/trunk/python/TorCtl/SQLSupport.py
Log:

Fix an exception crash on stream closing and kill a WARN.



Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py	2009-09-08 19:29:04 UTC (rev 20501)
+++ torctl/trunk/python/TorCtl/PathSupport.py	2009-09-08 19:31:53 UTC (rev 20502)
@@ -1395,7 +1395,11 @@
     """ Close all open streams """
     for strm in self.streams.itervalues():
       if not strm.ignored:
-        self.c.close_stream(strm.strm_id, reason)
+        try:
+          self.c.close_stream(strm.strm_id, reason)
+        except TorCtl.ErrorReply, e:
+          # This can happen. Streams can timeout before this call.
+          plog("NOTICE", "Error closing stream "+str(strm.strm_id)+": "+str(e))
 
   def close_all_circuits(self):
     """ Close all open circuits """

Modified: torctl/trunk/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/SQLSupport.py	2009-09-08 19:29:04 UTC (rev 20501)
+++ torctl/trunk/python/TorCtl/SQLSupport.py	2009-09-08 19:31:53 UTC (rev 20502)
@@ -931,7 +931,9 @@
       return
 
     strm = Stream.query.filter_by(strm_id = s.strm_id).first()
-    if self.track_parent and s.strm_id not in self.parent_handler.streams:
+    if self.track_parent and \
+      (s.strm_id not in self.parent_handler.streams or \
+           self.parent_handler.streams[s.strm_id].ignored):
       if strm:
         tc_session.delete(strm)
         tc_session.commit()



More information about the tor-commits mailing list