[or-cvs] r19578: {torctl} Add close_all_streams to support Tor exit hang workaround. A (torctl/trunk/python/TorCtl)
mikeperry at seul.org
mikeperry at seul.org
Thu May 28 12:21:43 UTC 2009
Author: mikeperry
Date: 2009-05-28 08:21:43 -0400 (Thu, 28 May 2009)
New Revision: 19578
Modified:
torctl/trunk/python/TorCtl/PathSupport.py
torctl/trunk/python/TorCtl/SQLSupport.py
Log:
Add close_all_streams to support Tor exit hang workaround.
Also fix some casting issues.
Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py 2009-05-28 12:21:01 UTC (rev 19577)
+++ torctl/trunk/python/TorCtl/PathSupport.py 2009-05-28 12:21:43 UTC (rev 19578)
@@ -1355,6 +1355,11 @@
e.g. for generating paths without actually creating any circuits """
return self.selmgr.select_path()
+ def close_all_streams(self, reason):
+ """ Close all open streams """
+ for strm in self.streams.itervalues():
+ self.c.close_stream(strm.strm_id, reason)
+
def close_all_circuits(self):
""" Close all open circuits """
for circ in self.circuits.itervalues():
Modified: torctl/trunk/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/SQLSupport.py 2009-05-28 12:21:01 UTC (rev 19577)
+++ torctl/trunk/python/TorCtl/SQLSupport.py 2009-05-28 12:21:43 UTC (rev 19578)
@@ -588,7 +588,7 @@
f.write(str(int(time.time()))+"\n")
def cvt(a,b,c=1):
- if type(a) == float: return round(a/c,b)
+ if type(a) == float: return int(round(a/c,b))
elif type(a) == int: return a
elif type(a) == type(None): return "None"
else: return type(a)
@@ -596,8 +596,8 @@
for s in RouterStats.query.filter(pct_clause).filter(stat_clause).\
order_by(order_by).all():
f.write("node_id=$"+s.router.idhex+" nick="+s.router.nickname)
- f.write(" strm_bw="+str(int(cvt(s.sbw,0))))
- f.write(" filt_bw="+str(int(cvt(s.filt_sbw,0))))
+ f.write(" strm_bw="+str(cvt(s.sbw,0)))
+ f.write(" filt_bw="+str(cvt(s.filt_sbw,0)))
f.write(" ns_bw="+str(int(cvt(s.avg_bw,0)))+"\n")
f.flush()
More information about the tor-commits
mailing list